libmultipath/discovery.c: handle errors from sscanf()
authorHannes Reinecke <hare@suse.de>
Wed, 15 Jun 2016 12:07:11 +0000 (14:07 +0200)
committerHannes Reinecke <hare@suse.de>
Thu, 16 Jun 2016 08:46:17 +0000 (10:46 +0200)
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
libmultipath/discovery.c

index db82b00..5d5441d 100644 (file)
@@ -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;
 }