[PATCH 5/6] Fix broken major:minor device handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



devt2devname was not actually setting devname, so multipath was not able to
do operate on devices using major:minor

This patch sets devname, and also checks for an unlikely buffer overrun.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/discovery.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: multipath-tools-081203/libmultipath/discovery.c
===================================================================
--- multipath-tools-081203.orig/libmultipath/discovery.c
+++ multipath-tools-081203/libmultipath/discovery.c
@@ -253,7 +253,11 @@ devt2devname (char *devname, char *devt)
 			continue;
 
 		if ((major == tmpmaj) && (minor == tmpmin)) {
-			sprintf(block_path, "/sys/block/%s", dev);
+			if (snprintf(block_path, FILE_NAME_SIZE, "/sys/block/%s", dev) >= FILE_NAME_SIZE) {
+				condlog(0, "device name %s is too long\n", dev);
+				fclose(fd);
+				return 1;
+			}
 			break;
 		}
 	}
@@ -271,6 +275,7 @@ devt2devname (char *devname, char *devt)
 		condlog(0, "sysfs entry %s is not a directory\n", block_path);
 		return 1;
 	}
+	basename(block_path, devname);
 	return 0;
 }
 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux