summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <david@fubar.dk>2004-03-30 17:13:48 +0000
committerDavid Zeuthen <david@fubar.dk>2004-03-30 17:13:48 +0000
commit1ef0b081c5192cbf9d8eef871e11eb633bf6009d (patch)
tree8869777d8f8fd6922b26c894d6697fb35188bfa9
parent11a968c5c4a49207645594bbb5e729f56994661a (diff)
add a "strcat_len()" macro and use itHAL_GOBJECT_BRANCHPOINT
-rw-r--r--ChangeLog4
-rw-r--r--tools/linux/hal_hotplug.c15
2 files changed, 14 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 45da351b..2c0bab12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2004-03-29 Robert Love <rml@ximian.com>
+ * tools/linux/hal_hotplug.c: add a "strcat_len()" macro and use it
+
+2004-03-29 Robert Love <rml@ximian.com>
+
* tools/linux/hal_hotplug.c: sysfs_mnt_path should be a "char []"
not a "char * []", also use PATH_MAX instead of 255, and finally
use "const char" as appropriate
diff --git a/tools/linux/hal_hotplug.c b/tools/linux/hal_hotplug.c
index ef5ab527..10a5c8d6 100644
--- a/tools/linux/hal_hotplug.c
+++ b/tools/linux/hal_hotplug.c
@@ -138,6 +138,12 @@ static const char *file_list_pci[] = {
NULL
};
+/* safely strcat() at most the remaining space in 'dst' */
+#define strcat_len(dst, src) do { \
+ dst[sizeof (dst) - 1] = '\0'; \
+ strncat (dst, src, sizeof (dst) - strlen (dst) - 1); \
+} while(0)
+
static int
wait_for_sysfs_info (char *devpath, char *hotplug_type)
{
@@ -206,7 +212,7 @@ wait_for_sysfs_info (char *devpath, char *hotplug_type)
/* first, check directory */
strncpy (path, sysfs_mnt_path, PATH_MAX);
- strncat (path, devpath, PATH_MAX);
+ strcat_len (path, devpath);
/*printf("path0 = %s\n", path); */
@@ -221,10 +227,9 @@ wait_for_sysfs_info (char *devpath, char *hotplug_type)
file = file_list[i];
strncpy (path, sysfs_mnt_path, PATH_MAX);
- strncat (path, devpath, PATH_MAX);
- strncat (path, "/", PATH_MAX);
- strncat (path, file, PATH_MAX);
-
+ strcat_len (path, devpath);
+ strcat_len (path, "/");
+ strcat_len (path, file);
/*printf("path1 = %s\n", path); */
rc = stat (path, &stat_buf);