hal/hald/linux2/probing Makefile.am, 1.8, 1.9 probe-volume.c, 1.15,
1.16
Danny Kukawka
dkukawka at freedesktop.org
Thu Aug 25 12:36:31 PDT 2005
Update of /cvs/hal/hal/hald/linux2/probing
In directory gabe:/tmp/cvs-serv12082/hald/linux2/probing
Modified Files:
Makefile.am probe-volume.c
Log Message:
2005-08-25 Danny Kukawka <danny.kukawka at web.de>
* hald/linux2/probing/Makefile.am: Added glib to Makefile.
* hald/linux2/probing/probe-volume.c: (strdup_valid_utf8),
(set_volume_id_values): Fix to prevent sending invalid UTF8
strings from volumelabels to D-BUS. The invalid, non UTF8,
characters replaced now with '?'.
Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Makefile.am 23 Jun 2005 14:50:05 -0000 1.8
+++ Makefile.am 25 Aug 2005 19:36:29 -0000 1.9
@@ -31,8 +31,8 @@
hald_probe_pc_floppy_SOURCES = probe-pc-floppy.c
-hald_probe_volume_SOURCES = probe-volume.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h shared.h
-hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/drive_id/libdrive_id.la $(top_builddir)/volume_id/libvolume_id.la
+hald_probe_volume_SOURCES = probe-volume.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h shared.h
+hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/drive_id/libdrive_id.la $(top_builddir)/volume_id/libvolume_id.la @PACKAGE_LIBS@
Index: probe-volume.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/probe-volume.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- probe-volume.c 23 Aug 2005 20:29:43 -0000 1.15
+++ probe-volume.c 25 Aug 2005 19:36:29 -0000 1.16
@@ -44,6 +44,8 @@
#include <time.h>
#include <sys/time.h>
+#include <glib.h>
+
#include "libhal/libhal.h"
#include "drive_id/drive_id.h"
@@ -56,6 +58,23 @@
#include "shared.h"
+static char *
+strdup_valid_utf8 ( const char *String )
+{
+ char *endchar;
+ char *newString;
+
+ if (String == NULL)
+ return NULL;
+
+ newString = g_strdup( String );
+
+ while (!g_utf8_validate (newString, -1, (const char **) &endchar)) {
+ *endchar = '?';
+ }
+ return newString;
+}
+
void
volume_id_log (const char *format, ...)
{
@@ -69,6 +88,7 @@
{
char buf[256];
const char *usage;
+ char *volume_label;
DBusError error;
dbus_error_init (&error);
@@ -108,11 +128,15 @@
}
libhal_device_set_property_string (ctx, udi, "volume.uuid", vid->uuid, &error);
dbg ("volume.uuid = '%s'", vid->uuid);
- libhal_device_set_property_string (ctx, udi, "volume.label", vid->label, &error);
- dbg ("volume.label = '%s'", vid->label);
- if (vid->label[0] != '\0') {
- libhal_device_set_property_string (ctx, udi, "info.product", vid->label, &error);
+ /* 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_device_set_property_string (ctx, udi, "volume.label", volume_label, &error);
+ dbg ("volume.label = '%s'", volume_label);
+
+ libhal_device_set_property_string (ctx, udi, "info.product", volume_label, &error);
+ g_free(volume_label);
} else {
snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
libhal_device_set_property_string (ctx, udi, "info.product", buf, &error);
More information about the hal-commit
mailing list