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

stage1: Fix segfault in enterexec #2608

Merged
merged 1 commit into from May 12, 2016
Merged

Conversation

euank
Copy link
Member

@euank euank commented May 11, 2016

Prior to this commit, if rkt enter was executed without the TERM
environment variable set, a segfault could occur.
This commit treats an unset TERM environment variable as meaning 'xterm'
and avoids the segfault.

This is more noticeable in environments where rkt is the child of some non-terminal process (e.g. the kubelet).

Related to kubernetes/kubernetes#25430

I reproduced this via sudo sh -c 'unset TERM && rkt enter $uid ls' on my machine, though I'm not certain that it reproduces consistently on all machines. I could not reproduce it after this change.

I wasn't sure if it was preferable to leave TERM blank when it is unset for the caller and I'm open for any discussion / arguments there.

cc @dgonyeo

if (entering) {
// enter is typically interactive; ensure we always have a sane enough term
// variable.
if(term == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a space before the opening parenthesis

// enter is typically interactive; ensure we always have a sane enough term
// variable.
if(term == NULL) {
setenv("TERM", "xterm", 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer in this place more simple vt100 assumption.

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.
@euank
Copy link
Member Author

euank commented May 11, 2016

Addressed both comments as suggested, PTAL

@jonboulle
Copy link
Contributor

LGTM on green

@jonboulle jonboulle merged commit 78087b6 into rkt:master May 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants