mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
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:
1 parent
920df09cd5
commit
faca84a590
2 files changed
+4
-3
No files matched your search
+2
-2
@@ -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 void pidfile_callback(void *arg, int fd, int events)
|
||||||
{
|
{
|
||||||
static char ev_buf[8 *(sizeof(struct inotify_event) + NAME_MAX + 1) + 1];
|
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;
|
struct inotify_event *ev;
|
||||||
ssize_t sz, len;
|
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 void pidfile_reconf(void *_null)
|
||||||
{
|
{
|
||||||
static char cond[MAX_ARG_LEN];
|
static char cond[MAX_COND_LEN];
|
||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
(void)(_null);
|
(void)(_null);
|
||||||
int restart = 0;
|
int restart = 0;
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ typedef enum {
|
|||||||
#define FINIT_SHM_ID 0x494E4954 /* "INIT", see ascii(7) */
|
#define FINIT_SHM_ID 0x494E4954 /* "INIT", see ascii(7) */
|
||||||
#define MAX_ARG_LEN 64
|
#define MAX_ARG_LEN 64
|
||||||
#define MAX_STR_LEN 64
|
#define MAX_STR_LEN 64
|
||||||
|
#define MAX_COND_LEN (MAX_ARG_LEN * 3)
|
||||||
#define MAX_USER_LEN 16
|
#define MAX_USER_LEN 16
|
||||||
#define MAX_NUM_FDS 64 /* Max number of I/O plugins */
|
#define MAX_NUM_FDS 64 /* Max number of I/O plugins */
|
||||||
#define MAX_NUM_SVC 64 /* Enough? */
|
#define MAX_NUM_SVC 64 /* Enough? */
|
||||||
@@ -94,7 +95,7 @@ typedef struct svc {
|
|||||||
int runlevels;
|
int runlevels;
|
||||||
int sighup; /* This service supports SIGHUP :) */
|
int sighup; /* This service supports SIGHUP :) */
|
||||||
svc_block_t block; /* Reason that this service is currently stopped */
|
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. */
|
/* Incremented for each restart by service monitor. */
|
||||||
const unsigned int restart_counter;
|
const unsigned int restart_counter;
|
||||||
|
|||||||
Reference in new issue
Block a user