mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zpcictl: Check for regular directory
In case a regular directory was specified, rather than a device node, the check if the device exists will pass. The following code paths then assume a slot id was specified. This in turn may lead to a buffer overflow when the device data is copied to to the zpci_device struct. Check if the specified path is a regular directory and prevent a possible later buffer overflow and copying wrong data respectively. Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -253,8 +253,12 @@ static int device_exists(char *dev)
|
||||
char *path;
|
||||
int rc = 0;
|
||||
|
||||
/* In case a device node is specified, this will be sufficiant */
|
||||
if (util_path_exists(dev) && !util_path_is_dir(dev))
|
||||
return 1;
|
||||
|
||||
path = util_path_sysfs("bus/pci/devices/%s", dev);
|
||||
if (util_path_exists(path) || util_path_exists(dev))
|
||||
if (util_path_exists(path))
|
||||
rc = 1;
|
||||
free(path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user