From 5d6d5f85d8ed49698eb3d790308e05a50b784c54 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 17 Jul 2015 14:08:36 +0200 Subject: flowtop: Use strncpy instead of strcat Make the path creation a bit more straight-forward. Signed-off-by: Tobias Klauser --- flowtop.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/flowtop.c b/flowtop.c index a6f8fc1..7fd9055 100644 --- a/flowtop.c +++ b/flowtop.c @@ -231,8 +231,7 @@ static int sysctl_set_int(char *file, int value) ssize_t ret; int fd; - path[0] = '\0'; - strcat(path, SYS_PATH); + strncpy(path, SYS_PATH, PATH_MAX); strncat(path, file, PATH_MAX - sizeof(SYS_PATH) - 1); fd = open(path, O_WRONLY); @@ -258,8 +257,7 @@ static int sysctl_get_int(char *file, int *value) ssize_t ret; int fd; - path[0] = '\0'; - strcat(path, SYS_PATH); + strncpy(path, SYS_PATH, PATH_MAX); strncat(path, file, PATH_MAX - sizeof(SYS_PATH) - 1); fd = open(path, O_RDONLY); -- cgit v1.2.3-54-g00ecf