Merge "init: Fix potential null pointer issue"
This commit is contained in:
commit
1615c09ac1
1 changed files with 9 additions and 9 deletions
18
init/init.c
18
init/init.c
|
|
@ -90,7 +90,7 @@ void notify_service_state(const char *name, const char *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int have_console;
|
static int have_console;
|
||||||
static char *console_name = "/dev/console";
|
static char console_name[PROP_VALUE_MAX] = "/dev/console";
|
||||||
static time_t process_needs_restart;
|
static time_t process_needs_restart;
|
||||||
|
|
||||||
static const char *ENV[32];
|
static const char *ENV[32];
|
||||||
|
|
@ -430,7 +430,7 @@ static void restart_processes()
|
||||||
|
|
||||||
static void msg_start(const char *name)
|
static void msg_start(const char *name)
|
||||||
{
|
{
|
||||||
struct service *svc;
|
struct service *svc = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
char *args = NULL;
|
char *args = NULL;
|
||||||
|
|
||||||
|
|
@ -438,11 +438,13 @@ static void msg_start(const char *name)
|
||||||
svc = service_find_by_name(name);
|
svc = service_find_by_name(name);
|
||||||
else {
|
else {
|
||||||
tmp = strdup(name);
|
tmp = strdup(name);
|
||||||
args = strchr(tmp, ':');
|
if (tmp) {
|
||||||
*args = '\0';
|
args = strchr(tmp, ':');
|
||||||
args++;
|
*args = '\0';
|
||||||
|
args++;
|
||||||
|
|
||||||
svc = service_find_by_name(tmp);
|
svc = service_find_by_name(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svc) {
|
if (svc) {
|
||||||
|
|
@ -547,11 +549,9 @@ static int keychord_init_action(int nargs, char **args)
|
||||||
static int console_init_action(int nargs, char **args)
|
static int console_init_action(int nargs, char **args)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char tmp[PROP_VALUE_MAX];
|
|
||||||
|
|
||||||
if (console[0]) {
|
if (console[0]) {
|
||||||
snprintf(tmp, sizeof(tmp), "/dev/%s", console);
|
snprintf(console_name, sizeof(console_name), "/dev/%s", console);
|
||||||
console_name = strdup(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open(console_name, O_RDWR);
|
fd = open(console_name, O_RDWR);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue