Bug 24468 – part-id crashes if drive device node does not exist
authorMartin Pitt <martin.pitt@ubuntu.com>
Mon, 12 Oct 2009 08:37:11 +0000 (10:37 +0200)
committerDavid Zeuthen <davidz@redhat.com>
Thu, 15 Oct 2009 20:28:48 +0000 (16:28 -0400)
This fixes a corner case crash if a partition device node exists (like
/dev/sda5), but the corresponding drive device node (like /dev/sda) does not.
This should not happen in a running system, but was reported to occur during a
distribution upgrade.

Just handle the situation gracefully with a proper error message instead of
crashing.

http://bugs.freedesktop.org/show_bug.cgi?id=24468

Signed-off-by: David Zeuthen <davidz@redhat.com>
src/part-id.c

index 314fc5f..c821147 100644 (file)
@@ -158,6 +158,12 @@ main (int argc, char *argv[])
                 }
                 partition_table_device_file = g_strdup (udev_device_get_devnode (device));
                 udev_device_unref (device);
+                if (partition_table_device_file == NULL) {
+                       /* This Should Not Happen™, but was reported in a distribution upgrade 
+                          scenario, so handle it gracefully */
+                        g_printerr ("Error getting devnode from udev device path %s: %m\n", partition_table_devpath);
+                        goto out;
+                }
                 g_free (partition_table_devpath);
         } else {
                 /* not partition */