hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Thu Dec 6 01:25:23 PST 2007


 libhal/libhal.c |  152 +++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 107 insertions(+), 45 deletions(-)

New commits:
commit 1be50e5c71fe0db721958668b9bc53dc20cfc502
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Dec 6 10:25:07 2007 +0100

    add udi and some more checks to libhal
    
    This adds:
    - a minimal check if a given UDI is valid (checks if the UDI starts
    with '/org/freedesktop/Hal/devices/'). This should prevent possible
    (application) crashes if a invalid UDI is send to HAL and reduce
    unneeded dbus calls.
    - some more parameter checks (for LibHalChangeSet, keys ...)

diff --git a/libhal/libhal.c b/libhal/libhal.c
index 1e66bf4..3f6a9a0 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -74,6 +74,30 @@
 		}								\
 	} while(0)
 
+/**
+ * LIBHAL_CHECK_UDI_VALID:
+ * @_udi_: the UID to check for 
+ * @_ret_:   what to use for return value if udi is invalid 
+ *
+ * Handy macro for checking whether a UID is valid and not NULL.
+ */
+#define LIBHAL_CHECK_UDI_VALID(_udi_,_ret_)						\
+	do {										\
+		if (_udi_ == NULL) {							\
+			fprintf (stderr,						\
+				 "%s %d : invalid udi %s. udi is NULL.\n",  		\
+				 __FILE__, __LINE__, _udi_);	 			\
+			return _ret_;							\
+		} else {								\
+			if(strncmp(_udi_, "/org/freedesktop/Hal/devices/", 29) != 0) {	\
+				fprintf (stderr,					\
+                                 	 "%s %d : invalid udi: %s doesn't start"	\
+					 "with '/org/freedesktop/Hal/devices/'. \n",    \
+	                                 __FILE__, __LINE__, _udi_);			\
+				return _ret_;						\
+			}								\
+		}									\
+	} while(0)
 
 static char **libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements);
 
@@ -319,6 +343,10 @@ static dbus_bool_t
 libhal_property_fill_value_from_variant (LibHalProperty *p, DBusMessageIter *var_iter)
 {
 	DBusMessageIter iter_array;
+
+	LIBHAL_CHECK_PARAM_VALID(p, "LibHalProperty *p", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(var_iter, "DBusMessageIter *var_iter", FALSE);
+
 	switch (p->type) {
 	case DBUS_TYPE_ARRAY:
 		if (dbus_message_iter_get_element_type (var_iter) != DBUS_TYPE_STRING)
@@ -496,7 +524,7 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
+	LIBHAL_CHECK_UDI_VALID(udi, NULL);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
 						"org.freedesktop.Hal.Device",
@@ -1282,7 +1310,7 @@ libhal_device_get_property_type (LibHalContext *ctx, const char *udi, const char
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, LIBHAL_PROPERTY_TYPE_INVALID); /* or return NULL? */
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", LIBHAL_PROPERTY_TYPE_INVALID);
+	LIBHAL_CHECK_UDI_VALID(udi, LIBHAL_PROPERTY_TYPE_INVALID);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", LIBHAL_PROPERTY_TYPE_INVALID);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1344,7 +1372,7 @@ libhal_device_get_property_strlist (LibHalContext *ctx, const char *udi, const c
 	DBusError _error;
 	
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
+	LIBHAL_CHECK_UDI_VALID(udi, NULL);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", NULL);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1417,7 +1445,7 @@ libhal_device_get_property_string (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
+	LIBHAL_CHECK_UDI_VALID(udi, NULL);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", NULL);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1495,7 +1523,7 @@ libhal_device_get_property_int (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, -1);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", -1);
+	LIBHAL_CHECK_UDI_VALID(udi, -1);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", -1);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1568,7 +1596,7 @@ libhal_device_get_property_uint64 (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, -1);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", -1);
+	LIBHAL_CHECK_UDI_VALID(udi, -1);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", -1);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1640,7 +1668,7 @@ libhal_device_get_property_double (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, -1.0);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", -1.0);
+	LIBHAL_CHECK_UDI_VALID(udi, -1.0);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", -1.0);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1712,7 +1740,7 @@ libhal_device_get_property_bool (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -1782,7 +1810,7 @@ libhal_device_set_property_helper (LibHalContext *ctx,
 	char *method_name = NULL;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 
 	/** @todo  sanity check incoming params */
@@ -1880,8 +1908,9 @@ libhal_device_set_property_string (LibHalContext *ctx,
 				   DBusError *error)
 {
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
 	
 	return libhal_device_set_property_helper (ctx, udi, key,
 						  DBUS_TYPE_STRING,
@@ -1906,7 +1935,7 @@ libhal_device_set_property_int (LibHalContext *ctx, const char *udi,
 				const char *key, dbus_int32_t value, DBusError *error)
 {
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 	
 	return libhal_device_set_property_helper (ctx, udi, key,
@@ -1932,7 +1961,7 @@ libhal_device_set_property_uint64 (LibHalContext *ctx, const char *udi,
 				   const char *key, dbus_uint64_t value, DBusError *error)
 {
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 	
 	return libhal_device_set_property_helper (ctx, udi, key,
@@ -1958,7 +1987,7 @@ libhal_device_set_property_double (LibHalContext *ctx, const char *udi,
 				   const char *key, double value, DBusError *error)
 {
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 	
 	return libhal_device_set_property_helper (ctx, udi, key,
@@ -1984,7 +2013,7 @@ libhal_device_set_property_bool (LibHalContext *ctx, const char *udi,
 				 const char *key, dbus_bool_t value, DBusError *error)
 {
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 	
 	return libhal_device_set_property_helper (ctx, udi, key,
@@ -2010,7 +2039,7 @@ libhal_device_remove_property (LibHalContext *ctx,
 			       const char *udi, const char *key, DBusError *error)
 {
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 	
 	return libhal_device_set_property_helper (ctx, udi, key, DBUS_TYPE_INVALID,	
@@ -2043,8 +2072,9 @@ libhal_device_property_strlist_append (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
 						"org.freedesktop.Hal.Device",
@@ -2098,8 +2128,9 @@ libhal_device_property_strlist_prepend (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
 						"org.freedesktop.Hal.Device",
@@ -2153,7 +2184,7 @@ libhal_device_property_strlist_remove_index (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -2207,8 +2238,9 @@ libhal_device_property_strlist_remove (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
 						"org.freedesktop.Hal.Device",
@@ -2261,7 +2293,7 @@ libhal_device_lock (LibHalContext *ctx,
 	DBusMessage *reply;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	if (reason_why_locked != NULL)
 		*reason_why_locked = NULL;
@@ -2331,7 +2363,7 @@ libhal_device_unlock (LibHalContext *ctx,
 	DBusMessage *reply;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						udi,
@@ -2468,8 +2500,8 @@ libhal_device_commit_to_gdl (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(temp_udi, "*temp_udi", FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(temp_udi, FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						"/org/freedesktop/Hal/Manager",
@@ -2527,7 +2559,7 @@ libhal_remove_device (LibHalContext *ctx, const char *udi, DBusError *error)
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						"/org/freedesktop/Hal/Manager",
@@ -2581,7 +2613,7 @@ libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error)
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						"/org/freedesktop/Hal/Manager",
@@ -2653,7 +2685,7 @@ libhal_device_property_exists (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -2722,8 +2754,8 @@ libhal_merge_properties (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(target_udi, "*target_udi", FALSE);
-	LIBHAL_CHECK_PARAM_VALID(source_udi, "*sourcE_udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(target_udi, FALSE);
+	LIBHAL_CHECK_UDI_VALID(source_udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						"/org/freedesktop/Hal/Manager",
@@ -2791,8 +2823,8 @@ libhal_device_matches (LibHalContext *ctx,
 	DBusError _error;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi1, "*udi1", FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi2, "*udi2", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi1, FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi2, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(property_namespace, "*property_namespace", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
@@ -2863,7 +2895,7 @@ libhal_device_print (LibHalContext *ctx, const char *udi, DBusError *error)
 	LibHalPropertySetIterator i;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	printf ("device_id = %s\n", udi);
 
@@ -2952,6 +2984,7 @@ libhal_manager_find_device_string_match (LibHalContext *ctx,
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", NULL);
+	LIBHAL_CHECK_PARAM_VALID(value, "*value", NULL);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						"/org/freedesktop/Hal/Manager",
@@ -3021,7 +3054,7 @@ libhal_device_add_capability (LibHalContext *ctx,
 	DBusMessageIter iter;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(capability, "*capability", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
@@ -3076,7 +3109,7 @@ libhal_device_query_capability (LibHalContext *ctx, const char *udi, const char
 	dbus_bool_t ret;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(capability, "*capability", FALSE);
 
 	ret = FALSE;
@@ -3211,7 +3244,7 @@ libhal_device_add_property_watch (LibHalContext *ctx, const char *udi, DBusError
 	char buf[512];
 	
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	snprintf (buf, 512,
 		  "type='signal',"
@@ -3242,7 +3275,7 @@ libhal_device_remove_property_watch (LibHalContext *ctx, const char *udi, DBusEr
 	char buf[512];
 	
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	snprintf (buf, 512,
 		  "type='signal',"
@@ -3685,7 +3718,7 @@ libhal_device_rescan (LibHalContext *ctx, const char *udi, DBusError *error)
 	dbus_bool_t result;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
 						"org.freedesktop.Hal.Device",
@@ -3745,7 +3778,7 @@ libhal_device_reprobe (LibHalContext *ctx, const char *udi, DBusError *error)
 	dbus_bool_t result;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						udi,
@@ -3813,8 +3846,9 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
 	dbus_bool_t result;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(condition_name, "*condition_name", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(condition_details, "*condition_details", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
 						udi,
@@ -3879,6 +3913,7 @@ addon_is_ready(LibHalContext *ctx, const char *identifier,
 	DBusMessage *reply;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+	LIBHAL_CHECK_PARAM_VALID(identifier, "*identifier", FALSE);
 
         if (singleton) {
         	message = dbus_message_new_method_call ("org.freedesktop.Hal",
@@ -3940,6 +3975,10 @@ libhal_device_addon_is_ready (LibHalContext *ctx,
 			      const char *udi,
 			      DBusError *error)
 {
+
+	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+
 	return addon_is_ready (ctx, udi, FALSE, error);
 }
 
@@ -3961,6 +4000,9 @@ libhal_device_singleton_addon_is_ready (LibHalContext *ctx,
 					const char *command_line,
 					DBusError *error)
 {
+	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+	LIBHAL_CHECK_PARAM_VALID(command_line, "*command_line", FALSE);
+		
 	return addon_is_ready (ctx, command_line, TRUE, error);
 }
 
@@ -3993,7 +4035,7 @@ libhal_device_claim_interface (LibHalContext *ctx,
 	dbus_bool_t result;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(interface_name, "*interface_name", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
@@ -4081,7 +4123,7 @@ libhal_device_new_changeset (const char *udi)
 {
 	LibHalChangeSet *changeset;
 
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 
 	changeset = calloc (1, sizeof (LibHalChangeSet));
 	if (changeset == NULL)
@@ -4104,6 +4146,9 @@ out:
 static void
 libhal_changeset_append (LibHalChangeSet *changeset, LibHalChangeSetElement *elem)
 {
+	LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", (void) NULL );
+	LIBHAL_CHECK_PARAM_VALID(elem, "*elem", (void) NULL);
+
 	if (changeset->head == NULL) {
 		changeset->head = elem;
 		changeset->tail = elem;
@@ -4133,6 +4178,7 @@ libhal_changeset_set_property_string (LibHalChangeSet *changeset, const char *ke
 {
 	LibHalChangeSetElement *elem;
 
+	LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
 	LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
 
@@ -4175,6 +4221,9 @@ libhal_changeset_set_property_int (LibHalChangeSet *changeset, const char *key,
 {
 	LibHalChangeSetElement *elem;
 
+	LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
 	elem = calloc (1, sizeof (LibHalChangeSetElement));
 	if (elem == NULL)
 		goto out;
@@ -4208,6 +4257,9 @@ libhal_changeset_set_property_uint64 (LibHalChangeSet *changeset, const char *ke
 {
 	LibHalChangeSetElement *elem;
 
+	LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
 	elem = calloc (1, sizeof (LibHalChangeSetElement));
 	if (elem == NULL)
 		goto out;
@@ -4241,6 +4293,9 @@ libhal_changeset_set_property_double (LibHalChangeSet *changeset, const char *ke
 {
 	LibHalChangeSetElement *elem;
 
+	LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
 	elem = calloc (1, sizeof (LibHalChangeSetElement));
 	if (elem == NULL)
 		goto out;
@@ -4274,6 +4329,9 @@ libhal_changeset_set_property_bool (LibHalChangeSet *changeset, const char *key,
 {
 	LibHalChangeSetElement *elem;
 
+	LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
 	elem = calloc (1, sizeof (LibHalChangeSetElement));
 	if (elem == NULL)
 		goto out;
@@ -4310,6 +4368,9 @@ libhal_changeset_set_property_strlist (LibHalChangeSet *changeset, const char *k
 	int len;
 	int i, j;
 
+        LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+        LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
 	elem = calloc (1, sizeof (LibHalChangeSetElement));
 	if (elem == NULL)
 		goto out;
@@ -4380,6 +4441,7 @@ libhal_device_commit_changeset (LibHalContext *ctx, LibHalChangeSet *changeset,
 	int i;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+	LIBHAL_CHECK_UDI_VALID(changeset->udi, FALSE);
 
 	if (changeset->head == NULL) {
 		return TRUE;
@@ -4547,7 +4609,7 @@ libhal_device_acquire_interface_lock (LibHalContext *ctx,
 	DBusMessage *reply;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(interface, "*interface", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
@@ -4605,7 +4667,7 @@ dbus_bool_t libhal_device_release_interface_lock (LibHalContext *ctx,
 	DBusMessage *reply;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", FALSE);
+	LIBHAL_CHECK_UDI_VALID(udi, FALSE);
 	LIBHAL_CHECK_PARAM_VALID(interface, "*interface", FALSE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
@@ -4780,7 +4842,7 @@ libhal_device_is_caller_locked_out (LibHalContext *ctx,
         dbus_bool_t value;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, TRUE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", TRUE);
+	LIBHAL_CHECK_UDI_VALID(udi, TRUE);
 	LIBHAL_CHECK_PARAM_VALID(interface, "*interface", TRUE);
 	LIBHAL_CHECK_PARAM_VALID(caller, "*caller", TRUE);
 
@@ -4922,7 +4984,7 @@ libhal_device_is_locked_by_others (LibHalContext *ctx,
         dbus_bool_t value;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, TRUE);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", TRUE);
+	LIBHAL_CHECK_UDI_VALID(udi, TRUE);
 	LIBHAL_CHECK_PARAM_VALID(interface, "*interface", TRUE);
 
 	message = dbus_message_new_method_call ("org.freedesktop.Hal",
@@ -4998,7 +5060,7 @@ libhal_device_is_caller_privileged (LibHalContext *ctx,
         char *value;
 
 	LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
-	LIBHAL_CHECK_PARAM_VALID(udi, "*udi", NULL);
+	LIBHAL_CHECK_UDI_VALID(udi, NULL);
 	LIBHAL_CHECK_PARAM_VALID(action, "*action", NULL);
 	LIBHAL_CHECK_PARAM_VALID(caller, "*caller", NULL);
 


More information about the hal-commit mailing list