hal/hald device_store.c,1.24,1.25

David Zeuthen david at freedesktop.org
Sun Jul 31 19:41:23 PDT 2005


Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv29681/hald

Modified Files:
	device_store.c 
Log Message:
2005-07-31  David Zeuthen  <davidz at redhat.com>

	* hald/device_store.c (hal_device_store_add): this is a patch to
	prevent adding a device with invalid UDI (doesn't start with
	"/org/freedesktop/Hal/devices/") to the 'global device
	list'. Without this patch it's possible to add a device with
	invalid UDI. If so, you can't see the device e.g. via lshal and
	get always a dbus error. Original patch from Danny Kukawka
	<danny.kukawka at web.de>; slightly tweaked.



Index: device_store.c
===================================================================
RCS file: /cvs/hal/hal/hald/device_store.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- device_store.c	29 Jul 2005 20:32:57 -0000	1.24
+++ device_store.c	1 Aug 2005 02:41:21 -0000	1.25
@@ -172,6 +172,14 @@
 void
 hal_device_store_add (HalDeviceStore *store, HalDevice *device)
 {
+	const char buf[] = "/org/freedesktop/Hal/devices/";
+
+	if (strncmp(device->udi, buf, sizeof (buf) - 1) != 0) {
+		
+		HAL_ERROR(("Can't add HalDevice with incorrect UDI. Valid "
+			   "UDI must start with '/org/freedesktop/Hal/devices/'"));
+		goto out;
+	}
 	store->devices = g_slist_prepend (store->devices,
 					  g_object_ref (device));
 
@@ -181,6 +189,9 @@
 			  G_CALLBACK (emit_device_capability_added), store);
 
 	g_signal_emit (store, signals[STORE_CHANGED], 0, device, TRUE);
+
+out:
+	;
 }
 
 gboolean




More information about the hal-commit mailing list