hal: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Wed Apr 18 12:20:31 PDT 2007


 hald/linux/probing/probe-volume.c |   40 +++++++++++++++++++++++---------------
 libhal/libhal.c                   |    3 ++
 2 files changed, 28 insertions(+), 15 deletions(-)

New commits:
diff-tree 87a6750f28d820628f74ad1cb39b3c94fa6ff9bd (from 49f699f3c2ea38fbfe1f75b004a5917ac482fe98)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Wed Apr 18 15:17:52 2007 -0400

    fix problems with case if vid->label[0] is '\0'
    
    Fix problems with the case where vid->label[0] is '\0'. Don't call
    strdup_valid_utf8 in this case, simply ignore the label in this case.
    Cleaned up the code to prevent code duplication.
    
    This fix fd.o bug #10362.

diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index b5f71c0..b003b25 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -131,38 +131,34 @@ set_volume_id_values (LibHalContext *ctx
 		libhal_changeset_set_property_string (cs, "volume.fsversion", vid->type_version);
 		HAL_DEBUG(("volume.fsversion = '%s'", vid->type_version));
 	}
+
 	libhal_changeset_set_property_string (cs, "volume.uuid", vid->uuid);
 	HAL_DEBUG(("volume.uuid = '%s'", vid->uuid));
 
-	/* we need to be sure for a utf8 valid label, because dbus accept only utf8 valid strings */
-	volume_label = strdup_valid_utf8 (vid->label);
-	if( volume_label != NULL ) {
-		libhal_changeset_set_property_string (cs, "volume.label", volume_label);
-		HAL_DEBUG(("volume.label = '%s'", volume_label));
+	if(vid->label != NULL && vid->label[0] != '\0') {
+		/* we need to be sure for a utf8 valid label, because dbus accept only utf8 valid strings */
+		volume_label = strdup_valid_utf8 (vid->label);
+		if( volume_label != NULL ) {
+			libhal_changeset_set_property_string (cs, "volume.label", volume_label);
+			HAL_DEBUG(("volume.label = '%s'", volume_label));
 		
-		if (strlen(volume_label) > 0) {	
-			libhal_changeset_set_property_string (cs, "info.product", volume_label);
-		}
-		else {
-			if (vid->type != NULL) {
-				snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
-			} else {
-				snprintf (buf, sizeof (buf), "Volume (unknown)");
+			if (strlen(volume_label) > 0) {	
+				libhal_changeset_set_property_string (cs, "info.product", volume_label);
+				g_free(volume_label);
+				return;
 			}
 
-			libhal_changeset_set_property_string (cs, "info.product", buf);
-				
-		}
-		g_free(volume_label);
-	} else {
-		if (vid->type != NULL) {
-			snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
-		} else {
-			snprintf (buf, sizeof (buf), "Volume (unknown)");
+			g_free(volume_label);
 		}
+	}
 
-		libhal_changeset_set_property_string (cs, "info.product", buf);
+	if (vid->type != NULL) {
+		snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
+	} else {
+		snprintf (buf, sizeof (buf), "Volume (unknown)");
 	}
+
+	libhal_changeset_set_property_string (cs, "info.product", buf);
 }
 
 static void
diff-tree 49f699f3c2ea38fbfe1f75b004a5917ac482fe98 (from b0e7e06138994fac45d08774a20774d04e8245de)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Wed Apr 18 15:17:18 2007 -0400

    fix possible segfault in probe-volume if vid->type == NULL
    
    Fix possible segfaults in probe-volume and libhal if vid->type ==
    NULL. Adde d checks for vid->type != NULL to probe-volume.c and new
    checks for parameter (LIBHAL_CHECK_PARAM_VALID) of
    libhal_changeset_set_property_string().
    
    This fix also fd.o bug #10429.

diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index d5963db..b5f71c0 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -122,8 +122,11 @@ set_volume_id_values (LibHalContext *ctx
 	libhal_changeset_set_property_string (cs, "volume.fsusage", usage);
 	HAL_DEBUG (("volume.fsusage = '%s'", usage));
 
-	libhal_changeset_set_property_string (cs, "volume.fstype", vid->type);
+	if (!libhal_changeset_set_property_string (cs, "volume.fstype", vid->type))
+		libhal_changeset_set_property_string (cs, "volume.fstype", "");
+
 	HAL_DEBUG(("volume.fstype = '%s'", vid->type));
+
 	if (vid->type_version[0] != '\0') {
 		libhal_changeset_set_property_string (cs, "volume.fsversion", vid->type_version);
 		HAL_DEBUG(("volume.fsversion = '%s'", vid->type_version));
@@ -141,12 +144,23 @@ set_volume_id_values (LibHalContext *ctx
 			libhal_changeset_set_property_string (cs, "info.product", volume_label);
 		}
 		else {
-			snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
+			if (vid->type != NULL) {
+				snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
+			} else {
+				snprintf (buf, sizeof (buf), "Volume (unknown)");
+			}
+
 			libhal_changeset_set_property_string (cs, "info.product", buf);
+				
 		}
 		g_free(volume_label);
 	} else {
-		snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
+		if (vid->type != NULL) {
+			snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
+		} else {
+			snprintf (buf, sizeof (buf), "Volume (unknown)");
+		}
+
 		libhal_changeset_set_property_string (cs, "info.product", buf);
 	}
 }
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 4ddac9e..fb9800a 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -3810,6 +3810,9 @@ libhal_changeset_set_property_string (Li
 {
 	LibHalChangeSetElement *elem;
 
+	LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+	LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
+
 	elem = calloc (1, sizeof (LibHalChangeSetElement));
 	if (elem == NULL)
 		goto out;


More information about the hal-commit mailing list