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 <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-19 09:58:05 +02:00
parent faca84a590
commit 13887f323a
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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;