summaryrefslogtreecommitdiffstats
path: root/init/init.c
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-04-05 19:56:27 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-05 19:56:27 -0700
commita5ca229a4571f6df42c96e760257b7ca95c7fdeb (patch)
treebdd703b6d4748b7112e7e8f67d0acadbf08b491c /init/init.c
parent2c1706675dfcab3205f4e065b63a5cef8acc3668 (diff)
parent1615c09ac1065104f56ddc444f5467aff76c0daa (diff)
downloadcore-a5ca229a4571f6df42c96e760257b7ca95c7fdeb.tar.gz
core-a5ca229a4571f6df42c96e760257b7ca95c7fdeb.tar.bz2
core-a5ca229a4571f6df42c96e760257b7ca95c7fdeb.zip
am 1615c09a: Merge "init: Fix potential null pointer issue"
* commit '1615c09ac1065104f56ddc444f5467aff76c0daa': init: Fix potential null pointer issue
Diffstat (limited to 'init/init.c')
-rwxr-xr-xinit/init.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/init/init.c b/init/init.c
index 93b59974f..f8b21e64a 100755
--- a/init/init.c
+++ b/init/init.c
@@ -90,7 +90,7 @@ void notify_service_state(const char *name, const char *state)
}
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 const char *ENV[32];
@@ -430,7 +430,7 @@ static void restart_processes()
static void msg_start(const char *name)
{
- struct service *svc;
+ struct service *svc = NULL;
char *tmp = NULL;
char *args = NULL;
@@ -438,11 +438,13 @@ static void msg_start(const char *name)
svc = service_find_by_name(name);
else {
tmp = strdup(name);
- args = strchr(tmp, ':');
- *args = '\0';
- args++;
+ if (tmp) {
+ args = strchr(tmp, ':');
+ *args = '\0';
+ args++;
- svc = service_find_by_name(tmp);
+ svc = service_find_by_name(tmp);
+ }
}
if (svc) {
@@ -547,11 +549,9 @@ static int keychord_init_action(int nargs, char **args)
static int console_init_action(int nargs, char **args)
{
int fd;
- char tmp[PROP_VALUE_MAX];
if (console[0]) {
- snprintf(tmp, sizeof(tmp), "/dev/%s", console);
- console_name = strdup(tmp);
+ snprintf(console_name, sizeof(console_name), "/dev/%s", console);
}
fd = open(console_name, O_RDWR);