diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-07-17 14:08:36 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-07-17 14:08:36 +0200 |
commit | 5d6d5f85d8ed49698eb3d790308e05a50b784c54 (patch) | |
tree | 927dda2191e1d11e451980ec91699e5612f2701c /flowtop.c | |
parent | e388315a03bcec355abc7bae4e0467e9e453284b (diff) |
flowtop: Use strncpy instead of strcat
Make the path creation a bit more straight-forward.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'flowtop.c')
-rw-r--r-- | flowtop.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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); |