summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@web.de>2007-04-18 15:17:18 -0400
committerDavid Zeuthen <davidz@redhat.com>2007-04-18 15:21:09 -0400
commitfd01460668e7e4f9de94021385c8c6f155a318b3 (patch)
tree4312c7fb427b54d497587b3f1512c16ed3335b0c
parentc8e4249b64b0a46b052ab3a83effc8986404e70c (diff)
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.
-rw-r--r--hald/linux/probing/probe-volume.c20
-rw-r--r--libhal/libhal.c3
2 files changed, 20 insertions, 3 deletions
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index d5963db9..b5f71c0f 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, const char *udi, LibHalChangeSet *cs,
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, const char *udi, LibHalChangeSet *cs,
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 8e760321..0f229c53 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -3821,6 +3821,9 @@ libhal_changeset_set_property_string (LibHalChangeSet *changeset, const char *ke
{
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;