From 75315e42a9294d01e23ff4df2826de8a69e5c93b Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 12 Oct 2009 10:37:11 +0200 Subject: [PATCH] =?utf8?q?Bug=2024468=20=E2=80=93=20part-id=20crashes=20if?= =?utf8?q?=20drive=20device=20node=20does=20not=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/part-id.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/part-id.c b/src/part-id.c index 314fc5f..c821147 100644 --- a/src/part-id.c +++ b/src/part-id.c @@ -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 */ -- 2.7.4