Fix Coverity CID 265222, guard init_request::data member

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-01-06 23:56:59 +01:00
parent ae9ed20d94
commit 7bf2fcb6e3
3 changed files with 7 additions and 2 deletions
+3
View File
@@ -275,6 +275,9 @@ static void api_cb(uev_t *w, void *arg, int events)
break;
}
/* Make sure no API using init_request::data can be abused */
rq.data_guard = 0;
if (rq.magic != INIT_MAGIC || len != sizeof(rq)) {
_e("Invalid initctl request");
break;
+3 -1
View File
@@ -84,12 +84,14 @@
#define INIT_CMD_NACK 254
#define INIT_CMD_ACK 255
/* Traditionally aligned on 384 bytes */
struct init_request {
int magic; /* Magic number */
int cmd; /* What kind of request */
int runlevel; /* Runlevel to change to */
int sleeptime; /* Time between TERM and KILL */
char data[368];
char data[367];
char data_guard; /* Forced to '\0' by Finit */
};
extern int runlevel;
+1 -1
View File
@@ -204,7 +204,7 @@ static void show_cond_one(const char *_conds)
static int do_cond_magic(char op, char *cond)
{
char event[368]; /* sizeof(init_request.data) */
char event[367]; /* sizeof(init_request.data) */
if (!cond || strlen(cond) < 1)
return 1;