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 -1
View File
@@ -68,6 +68,7 @@ typedef enum {
#define FINIT_SHM_ID 0x494E4954 /* "INIT", see ascii(7) */
#define MAX_ARG_LEN 64
#define MAX_STR_LEN 64
#define MAX_COND_LEN (MAX_ARG_LEN * 3)
#define MAX_USER_LEN 16
#define MAX_NUM_FDS 64 /* Max number of I/O plugins */
#define MAX_NUM_SVC 64 /* Enough? */
@@ -94,7 +95,7 @@ typedef struct svc {
int runlevels;
int sighup; /* This service supports SIGHUP :) */
svc_block_t block; /* Reason that this service is currently stopped */
char cond[MAX_ARG_LEN];
char cond[MAX_COND_LEN];
/* Incremented for each restart by service monitor. */
const unsigned int restart_counter;