mirror of
https://github.com/troglobit/finit.git
synced 2026-10-30 12:50:34 +00:00
Fix Coverity CID 265222, guard init_request::data member
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
ae9ed20d94
commit
7bf2fcb6e3
3 files changed
+7
-2
No files matched your search
@@ -275,6 +275,9 @@ static void api_cb(uev_t *w, void *arg, int events)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure no API using init_request::data can be abused */
|
||||||
|
rq.data_guard = 0;
|
||||||
|
|
||||||
if (rq.magic != INIT_MAGIC || len != sizeof(rq)) {
|
if (rq.magic != INIT_MAGIC || len != sizeof(rq)) {
|
||||||
_e("Invalid initctl request");
|
_e("Invalid initctl request");
|
||||||
break;
|
break;
|
||||||
|
|||||||
+3
-1
@@ -84,12 +84,14 @@
|
|||||||
#define INIT_CMD_NACK 254
|
#define INIT_CMD_NACK 254
|
||||||
#define INIT_CMD_ACK 255
|
#define INIT_CMD_ACK 255
|
||||||
|
|
||||||
|
/* Traditionally aligned on 384 bytes */
|
||||||
struct init_request {
|
struct init_request {
|
||||||
int magic; /* Magic number */
|
int magic; /* Magic number */
|
||||||
int cmd; /* What kind of request */
|
int cmd; /* What kind of request */
|
||||||
int runlevel; /* Runlevel to change to */
|
int runlevel; /* Runlevel to change to */
|
||||||
int sleeptime; /* Time between TERM and KILL */
|
int sleeptime; /* Time between TERM and KILL */
|
||||||
char data[368];
|
char data[367];
|
||||||
|
char data_guard; /* Forced to '\0' by Finit */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int runlevel;
|
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)
|
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)
|
if (!cond || strlen(cond) < 1)
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in new issue
Block a user