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 problem in condition parsing for very long
PID filenames which might be truncated in internal buffers
causing a mismatch in Finit condition tracking.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-19 09:58:05 +02:00
parent 920df09cd5
commit faca84a590
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ static char *mkcond(char *buf, size_t len, char *nm)
static void pidfile_callback(void *arg, int fd, int events)
{
static char ev_buf[8 *(sizeof(struct inotify_event) + NAME_MAX + 1) + 1];
static char cond[MAX_ARG_LEN];
static char cond[MAX_COND_LEN];
struct inotify_event *ev;
ssize_t sz, len;
@@ -94,7 +94,7 @@ static void pidfile_callback(void *arg, int fd, int events)
*/
static void pidfile_reconf(void *_null)
{
static char cond[MAX_ARG_LEN];
static char cond[MAX_COND_LEN];
svc_t *svc;
(void)(_null);
int restart = 0;