hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Mon Sep 11 14:36:13 PDT 2006


 hald/linux/coldplug.c |   63 ++++++++++++++++++++++++++++----------------------
 hald/linux/osspec.c   |   63 ++++++++++++++++++++++++++++----------------------
 2 files changed, 72 insertions(+), 54 deletions(-)

New commits:
diff-tree 9f6191e4df2dedb666883dab897b9e970a5bd001 (from 795688773dc98d87959e9b9531a6dbc58036b58c)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Sep 11 23:35:24 2006 +0200

    fixed usage of unchecked returnval from hal_util_strdup_valid_utf8
    
    Fixed usage of unchecked returnvalue from hal_util_strdup_valid_utf8.
    The function return NULL if there is no way to return a valid or a
    fixed validate string. A uncheck usage can cause this error:
    
       GLib-CRITICAL **: g_strlcpy: assertion `src != NULL' failed

diff --git a/hald/linux/coldplug.c b/hald/linux/coldplug.c
index e47a90f..db9e922 100644
--- a/hald/linux/coldplug.c
+++ b/hald/linux/coldplug.c
@@ -177,41 +177,50 @@ hal_util_init_sysfs_to_udev_map (void)
 			g_snprintf (hotplug_event->sysfs.device_file, sizeof(hotplug_event->sysfs.device_file),
 				    "%s/%s", dev_root, &line[3]);
 		} else if (strncmp(line, "E: ID_VENDOR=", 13) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[13]);
-			g_strlcpy (hotplug_event->sysfs.vendor, str, sizeof(hotplug_event->sysfs.vendor));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[13])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.vendor, str, sizeof(hotplug_event->sysfs.vendor));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_MODEL=", 12) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[12]);
-			g_strlcpy (hotplug_event->sysfs.model, str, sizeof(hotplug_event->sysfs.model));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[12])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.model, str, sizeof(hotplug_event->sysfs.model));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_REVISION=", 15) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[15]);
-			g_strlcpy (hotplug_event->sysfs.revision, str, sizeof(hotplug_event->sysfs.revision));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[15])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.revision, str, sizeof(hotplug_event->sysfs.revision));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_SERIAL=", 13) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[13]);
-			g_strlcpy (hotplug_event->sysfs.serial, str, sizeof(hotplug_event->sysfs.serial));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[13])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.serial, str, sizeof(hotplug_event->sysfs.serial));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_FS_USAGE=", 15) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[15]);
-			g_strlcpy (hotplug_event->sysfs.fsusage, str, sizeof(hotplug_event->sysfs.fsusage));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[15])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.fsusage, str, sizeof(hotplug_event->sysfs.fsusage));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_FS_TYPE=", 14) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[14]);
-			g_strlcpy (hotplug_event->sysfs.fstype, str, sizeof(hotplug_event->sysfs.fstype));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[14])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.fstype, str, sizeof(hotplug_event->sysfs.fstype));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_FS_VERSION=", 17) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[17]);
-			g_strlcpy (hotplug_event->sysfs.fsversion, str, sizeof(hotplug_event->sysfs.fsversion));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[17])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.fsversion, str, sizeof(hotplug_event->sysfs.fsversion));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_FS_UUID=", 14) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[14]);
-			g_strlcpy (hotplug_event->sysfs.fsuuid, str, sizeof(hotplug_event->sysfs.fsuuid));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[14])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.fsuuid, str, sizeof(hotplug_event->sysfs.fsuuid));
+				g_free (str);
+			}
 		} else if (strncmp(line, "E: ID_FS_LABEL=", 15) == 0) {
-			str = hal_util_strdup_valid_utf8(&line[15]);
-			g_strlcpy (hotplug_event->sysfs.fslabel, str, sizeof(hotplug_event->sysfs.fslabel));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&line[15])) != NULL) {
+				g_strlcpy (hotplug_event->sysfs.fslabel, str, sizeof(hotplug_event->sysfs.fslabel));
+				g_free (str);
+			}
 		}
 	}
 
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 9571d25..2d62f7a 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -161,41 +161,50 @@ hald_udev_data (GIOChannel *source, GIOC
 		else if (strncmp(key, "IFINDEX=", 8) == 0)
 			hotplug_event->sysfs.net_ifindex = strtoul(&key[8], NULL, 10);
 		else if (strncmp(key, "ID_VENDOR=", 10) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[10]);
-			g_strlcpy (hotplug_event->sysfs.vendor, str, sizeof(hotplug_event->sysfs.vendor));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[10])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.vendor, str, sizeof(hotplug_event->sysfs.vendor));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_MODEL=", 9) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[9]);
-			g_strlcpy (hotplug_event->sysfs.model, str, sizeof(hotplug_event->sysfs.model));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[9])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.model, str, sizeof(hotplug_event->sysfs.model));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_REVISION=", 12) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[12]);
-			g_strlcpy (hotplug_event->sysfs.revision, str, sizeof(hotplug_event->sysfs.revision));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[12])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.revision, str, sizeof(hotplug_event->sysfs.revision));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_SERIAL=", 10) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[10]);
-			g_strlcpy (hotplug_event->sysfs.serial, str, sizeof(hotplug_event->sysfs.serial));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[10])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.serial, str, sizeof(hotplug_event->sysfs.serial));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_FS_USAGE=", 12) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[12]);
-			g_strlcpy (hotplug_event->sysfs.fsusage, str, sizeof(hotplug_event->sysfs.fsusage));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[12])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.fsusage, str, sizeof(hotplug_event->sysfs.fsusage));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_FS_TYPE=", 11) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[11]);
-			g_strlcpy (hotplug_event->sysfs.fstype, str, sizeof(hotplug_event->sysfs.fstype));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[11])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.fstype, str, sizeof(hotplug_event->sysfs.fstype));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_FS_VERSION=", 14) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[14]);
-			g_strlcpy (hotplug_event->sysfs.fsversion, str, sizeof(hotplug_event->sysfs.fsversion));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[14])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.fsversion, str, sizeof(hotplug_event->sysfs.fsversion));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_FS_UUID=", 11) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[11]);
-			g_strlcpy (hotplug_event->sysfs.fsuuid, str, sizeof(hotplug_event->sysfs.fsuuid));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[11])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.fsuuid, str, sizeof(hotplug_event->sysfs.fsuuid));
+				g_free (str);
+			}
 		} else if (strncmp(key, "ID_FS_LABEL=", 12) == 0) {
-			str = hal_util_strdup_valid_utf8(&key[12]);
-			g_strlcpy (hotplug_event->sysfs.fslabel, str, sizeof(hotplug_event->sysfs.fslabel));
-			g_free (str);
+			if ((str = hal_util_strdup_valid_utf8(&key[12])) != NULL ) {
+				g_strlcpy (hotplug_event->sysfs.fslabel, str, sizeof(hotplug_event->sysfs.fslabel));
+				g_free (str);
+			}
 		}
 	}
 


More information about the hal-commit mailing list