severity 522136 important
tags 522136 patch
thanks

Raising severity as this completely breaks HAL on affected machines. 

Attached is a patch against 0.5.12~git20090406.46dc48-1 that fixes the
segfault for me.

"hal_device_property_get_string (parent, "storage.drive_type")" returns
NULL for these partitioned md-devices, which is passed to strcmp() and
causes the segfault.

NOTE: I don't know whether the actual bug is that parent points to the
wrong place, but this atleast gets HAL working again.

There are already similar reports in Ubuntu and upstream bugzilla:

https://bugs.launchpad.net/ubuntu/+source/hal/+bug/353396
https://bugs.freedesktop.org/show_bug.cgi?id=19577

-- 
Mika Tiainen            Always be wary of any helpful item that
mi...@iki.fi            weighs less than its operating manual.
http://mikat.iki.fi     -- (Terry Pratchett, Jingo)

Index: hal-0.5.12~git20090406.46dc48/hald/linux/blockdev.c
===================================================================
--- hal-0.5.12~git20090406.46dc48.orig/hald/linux/blockdev.c	2009-04-12 21:52:42.000000000 +0300
+++ hal-0.5.12~git20090406.46dc48/hald/linux/blockdev.c	2009-04-12 21:53:01.000000000 +0300
@@ -1498,8 +1498,14 @@
 		hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
 		hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
 		hal_device_property_set_bool (d, "volume.linux.is_device_mapper", is_device_mapper);
-		hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
 
+                if ((hal_device_property_get_string (parent, "storage.drive_type") != NULL) &&
+                    (strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0)) {
+                        hal_device_property_set_bool (d, "volume.is_disc", TRUE);
+                        hal_device_add_capability (d, "volume.disc");
+                } else {
+                        hal_device_property_set_bool (d, "volume.is_disc", FALSE);
+                }
 
 		is_physical_partition = TRUE;
 		if (is_fakevolume || is_device_mapper)
@@ -1508,9 +1514,6 @@
 		hal_device_property_set_bool (d, "volume.is_partition", is_physical_partition);
 
 		hal_device_property_set_string (d, "info.category", "volume");
-		if (strcmp(hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0) {
-			hal_device_add_capability (d, "volume.disc");
-		}
 		hal_device_add_capability (d, "volume");
 		hal_device_add_capability (d, "block");
 

Reply via email to