From 13887f323a117fd291fd4b3b427a599aca4d0a4e Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 19 Oct 2017 09:53:40 +0200 Subject: [PATCH] Fix GCC 7 string truncation warning, too small temporary buffer In GCC 7 the -Wall infers the new -Wformat-truncation which finds problems with string truncation in functions like snprintf(). This patch fixes a possibly problem in path name creation which, combined with the scandir() function, might cause loss of .conf files, failure to call run-parts properly, and kill services at shutdown. Signed-off-by: Joachim Nilsson --- src/conf.c | 2 +- src/exec.c | 2 +- src/sig.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf.c b/src/conf.c index 15f3971c..63bf64f2 100644 --- a/src/conf.c +++ b/src/conf.c @@ -470,7 +470,7 @@ int conf_reload_dynamic(void) for (i = 0; i < num; i++) { char *name = e[i]->d_name; - char path[CMD_SIZE]; + char path[LINE_SIZE]; size_t len; struct stat st; struct timeval mtime; diff --git a/src/exec.c b/src/exec.c index 7bb028c7..201745cc 100644 --- a/src/exec.c +++ b/src/exec.c @@ -354,7 +354,7 @@ int run_parts(char *dir, char *cmd) mode_t mode; char *args[NUM_ARGS]; char *name = e[i]->d_name; - char path[CMD_SIZE]; + char path[LINE_SIZE]; snprintf(path, sizeof(path), "%s/%s", dir, name); mode = fmode(path); diff --git a/src/sig.c b/src/sig.c index 93e2ec85..79ace6c4 100644 --- a/src/sig.c +++ b/src/sig.c @@ -116,7 +116,7 @@ void do_kill(int signo) while ((d = readdir(dirp))) { int pid; FILE *fp; - char file[80] = ""; + char file[LINE_SIZE] = ""; if (d->d_type != DT_DIR) continue;