From: Scott Parlane Date: Wed, 2 Sep 2020 05:01:11 +0000 (+1200) Subject: avoid a NULL pointer dereference in lxc-attach X-Git-Tag: lxc-5.0.0~360^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9346e19eb953c9f71d545019fc260da046e910f;p=thirdparty%2Flxc.git avoid a NULL pointer dereference in lxc-attach Seems to appear when stderr is a terminal and not stdin or stdout. Signed-off-by: Scott Parlane --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 4b9598922..368dd41ad 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1384,11 +1384,14 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, if (pid == 0) { if (options->attach_flags & LXC_ATTACH_TERMINAL) { - ret = pthread_sigmask(SIG_SETMASK, - &terminal.tty_state->oldmask, NULL); - if (ret < 0) { - SYSERROR("Failed to reset signal mask"); - _exit(EXIT_FAILURE); + if (terminal.tty_state) + { + ret = pthread_sigmask(SIG_SETMASK, + &terminal.tty_state->oldmask, NULL); + if (ret < 0) { + SYSERROR("Failed to reset signal mask"); + _exit(EXIT_FAILURE); + } } }