[PATCH 13/39] libmultipath/discovery.c: handle errors from sscanf()

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

 



Found by coverity.

Signed-off-by: Hannes Reinecke <hare@xxxxxxxx>
---
 libmultipath/discovery.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index db82b00..5d5441d 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1179,16 +1179,17 @@ ccw_sysfs_pathinfo (struct path * pp)
 	 */
 	attr_path = udev_device_get_sysname(parent);
 	pp->sg_id.lun = 0;
-	sscanf(attr_path, "%i.%i.%x",
-			&pp->sg_id.host_no,
-			&pp->sg_id.channel,
-			&pp->sg_id.scsi_id);
-	condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
+	if (sscanf(attr_path, "%i.%i.%x",
+		   &pp->sg_id.host_no,
+		   &pp->sg_id.channel,
+		   &pp->sg_id.scsi_id) == 3) {
+		condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
 			pp->dev,
 			pp->sg_id.host_no,
 			pp->sg_id.channel,
 			pp->sg_id.scsi_id,
 			pp->sg_id.lun);
+	}
 
 	return 0;
 }
-- 
2.6.6

--
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