mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
Fix Coverity CID 265222, guard init_request::data member
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user