hal: Branch 'hal-0_5_9-branch' - 2 commits
David Zeuthen
david at kemper.freedesktop.org
Wed Apr 18 12:21:23 PDT 2007
hald/linux/probing/probe-volume.c | 40 +++++++++++++++++++++++---------------
libhal/libhal.c | 3 ++
2 files changed, 28 insertions(+), 15 deletions(-)
New commits:
diff-tree 0523ace91d10d13ee84ddac8aa29cc4f33661e00 (from fd01460668e7e4f9de94021385c8c6f155a318b3)
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 fd01460668e7e4f9de94021385c8c6f155a318b3 (from c8e4249b64b0a46b052ab3a83effc8986404e70c)
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 8e76032..0f229c5 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -3821,6 +3821,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