hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Mon Oct 13 04:00:06 PDT 2008
hald/hald.c | 2 ++
hald/util.c | 20 ++++++++++++++++++++
hald/util.h | 2 ++
3 files changed, 24 insertions(+)
New commits:
commit fc4dfd1e119a549edc154ff5e16da2bd1494e10c
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Mon Oct 13 12:55:48 2008 +0200
fix udi: replace '/' in the last part of the udi
Fixed udi handling. DBus forbids a '/' after the base path
(in case of HAL: '/org/freedesktop/Hal/devices/) of a DBus
path. Replace all not allowed chars in the last part of the
UDI (everything but _a-zA-Z0-9) with a '_'.
This fixes also fd.o#16040.
diff --git a/hald/hald.c b/hald/hald.c
index a28d22e..051b33b 100644
--- a/hald/hald.c
+++ b/hald/hald.c
@@ -265,6 +265,8 @@ hald_compute_udi (gchar *dst, gsize dstsize, const gchar *format, ...)
hal_util_compute_udi_valist (hald_get_gdl (), dst, dstsize, format, args);
va_end (args);
+ hal_util_validate_udi (dst, dstsize);
+
if (hal_device_store_find (hald_get_gdl (), dst) == NULL &&
hal_device_store_find (hald_get_tdl (), dst) == NULL)
goto out;
diff --git a/hald/util.c b/hald/util.c
index 901e64f..81060e4 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -422,6 +422,26 @@ hal_util_compute_udi (HalDeviceStore *store, gchar *dst, gsize dstsize, const gc
va_end (args);
}
+void
+hal_util_validate_udi (gchar *udi, gsize size) {
+
+ char end[size];
+
+ if (sscanf (udi, "/org/freedesktop/Hal/devices/%s", end) == 1) {
+ if (strstr(end, "/") != NULL) {
+ HAL_DEBUG (("UDI end contains invalid char '/': '%s'", udi));
+
+ g_strcanon (end, "_"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "1234567890", '_');
+ g_snprintf (udi, size, "/org/freedesktop/Hal/devices/%s", end);
+
+ HAL_DEBUG (("Fixed UDI, replaced '/', new UDI: %s", udi));
+ }
+ }
+}
+
gboolean
hal_util_path_ascend (gchar *path)
diff --git a/hald/util.h b/hald/util.h
index 510c36c..5377e35 100644
--- a/hald/util.h
+++ b/hald/util.h
@@ -70,6 +70,8 @@ void hal_util_compute_udi_valist (HalDeviceStore *store, gchar *dst, gsize dstsi
void hal_util_compute_udi (HalDeviceStore *store, gchar *dst, gsize dstsize, const gchar *format, ...);
+void hal_util_validate_udi (gchar *udi, gsize size);
+
gboolean hal_util_path_ascend (gchar *path);
void hal_util_grep_discard_existing_data (void);
More information about the hal-commit
mailing list