Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
stage1: Fix segfault in enterexec
Browse files Browse the repository at this point in the history
Prior to this commit, if `rkt enter` was executed without the `TERM`
environment variable set, a segfault could occur.
This commit treats an empty TERM environment variable as meaning 'xterm'
and avoids the segfault.
  • Loading branch information
euank committed May 11, 2016
1 parent 38b4462 commit 2bdb549
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stage1/enterexec/enterexec.c
Expand Up @@ -209,6 +209,12 @@ static void set_env(const char *env_file)
static void load_env(const char *env_file, const char *keep_env_file, int entering)
{
char *term = getenv("TERM"); /* useful to keep during entering. */
if(entering && term == NULL) {
// enter is meant to operate in an interactive mode, make sure we always
// have a TERM variable
pexit_if((term = strdup("xterm")) == NULL,
"Failed to dup default term env");
}
pexit_if(clearenv() != 0,
"Unable to clear environment");

Expand Down

0 comments on commit 2bdb549

Please sign in to comment.