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 suppresses the warning by allowing only a subset of the
parent inetd service description to be copied to the child connection.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-19 09:58:05 +02:00
parent 13887f323a
commit 49481053a4
+5 -3
View File
@@ -176,8 +176,10 @@ static void socket_cb(uev_t *w, void *arg, int events)
/* Copy inherited attributes from inetd service's svc */
task->runlevels = svc->runlevels;
/* Only copy the most relevant parts of inetd, in particular we
* must *not* copy the watcher data to the clone! */
/*
* Only copy the most relevant parts of inetd, in particular we
* must *not* copy the watcher data to the clone!
*/
task->inetd.svc = svc;
task->inetd.cmd = svc->inetd.cmd;
task->inetd.type = svc->inetd.type;
@@ -186,7 +188,7 @@ static void socket_cb(uev_t *w, void *arg, int events)
memcpy(task->username, svc->username, sizeof(task->username));
memcpy(task->group, svc->group, sizeof(task->group));
memcpy(task->args, svc->args, sizeof(task->args));
snprintf(task->desc, sizeof(task->desc), "%s connection", svc->desc);
snprintf(task->desc, sizeof(task->desc), "%52.52s connection", svc->desc);
task->stdin_fd = stdin;
service_step(task);