From 5b86c76694dd86159cb78c238a100d7e62903770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albertas=20Vy=C5=A1niauskas?= Date: Tue, 17 May 2016 20:38:42 +0300 Subject: [PATCH] Fix SIGSEGV due to writes to const char array. If no console is configured, then the following code gets executed: int conf_parse_config(void) { ... char *fallback = FALLBACK_SHELL; ... tty_register(fallback); ... } int tty_register(char *line) { ... cmd = strtok(line, " "); ... } FALLBACK_SHELL is constant character array and strtok tries to modify the first argument, which causes a crash. --- conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 203cfa60..6ba4bf83 100644 --- a/conf.c +++ b/conf.c @@ -519,10 +519,12 @@ int conf_parse_config(void) result = parse_conf(FINIT_CONF); if (!tty_num()) { - char *fallback = FALLBACK_SHELL; + char *fallback = NULL; if (console) fallback = console; + else + fallback = strdup(FALLBACK_SHELL); tty_register(fallback); }