summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-07-17 14:08:36 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-07-17 14:08:36 +0200
commit5d6d5f85d8ed49698eb3d790308e05a50b784c54 (patch)
tree927dda2191e1d11e451980ec91699e5612f2701c
parente388315a03bcec355abc7bae4e0467e9e453284b (diff)
flowtop: Use strncpy instead of strcat
Make the path creation a bit more straight-forward. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--flowtop.c6
1 files 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);