From 63f61c5cf639953aa38e025485919b0aa1c49b59 Mon Sep 17 00:00:00 2001 From: "kay.sievers@vrfy.org" Date: Mon, 7 Mar 2005 04:29:43 +0100 Subject: [PATCH] replace strncpy()/strncat() by strlcpy()/strlcat() --- udev_multiplex.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'udev_multiplex.c') diff --git a/udev_multiplex.c b/udev_multiplex.c index 6d7852dbc0..3ef6e1707a 100644 --- a/udev_multiplex.c +++ b/udev_multiplex.c @@ -28,6 +28,7 @@ #include #include "udev.h" +#include "udev_libc_wrapper.h" #include "udev_utils.h" #include "logging.h" @@ -72,22 +73,22 @@ static int run_program(struct udevice *udev, const char *filename) */ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const char *suffix) { - char dirname[PATH_MAX]; + char dirname[PATH_SIZE]; /* chop the device name up into pieces based on '/' */ if (udev->name[0] != '\0') { - char devname[NAME_SIZE]; + char devname[PATH_SIZE]; char *temp; - strfieldcpy(devname, udev->name); + strlcpy(devname, udev->name, sizeof(devname)); temp = strchr(devname, '/'); while (temp != NULL) { temp[0] = '\0'; /* don't call the subsystem directory here */ if (strcmp(devname, udev->subsystem) != 0) { - snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname); - dirname[PATH_MAX-1] = '\0'; + snprintf(dirname, sizeof(dirname), "%s/%s", basedir, devname); + dirname[sizeof(dirname)-1] = '\0'; call_foreach_file(run_program, udev, dirname, suffix); } @@ -98,18 +99,18 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c } if (udev->name[0] != '\0') { - snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->name); - dirname[PATH_MAX-1] = '\0'; + snprintf(dirname, sizeof(dirname), "%s/%s", basedir, udev->name); + dirname[sizeof(dirname)-1] = '\0'; call_foreach_file(run_program, udev, dirname, suffix); } if (udev->subsystem[0] != '\0') { - snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->subsystem); - dirname[PATH_MAX-1] = '\0'; + snprintf(dirname, sizeof(dirname), "%s/%s", basedir, udev->subsystem); + dirname[sizeof(dirname)-1] = '\0'; call_foreach_file(run_program, udev, dirname, suffix); } - snprintf(dirname, PATH_MAX, "%s/default", basedir); - dirname[PATH_MAX-1] = '\0'; + snprintf(dirname, sizeof(dirname), "%s/default", basedir); + dirname[sizeof(dirname)-1] = '\0'; call_foreach_file(run_program, udev, dirname, suffix); } -- cgit v1.2.3-54-g00ecf