]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
avoid a NULL pointer dereference in lxc-attach
authorScott Parlane <scott.parlane@alliedtelesis.co.nz>
Wed, 2 Sep 2020 05:01:11 +0000 (17:01 +1200)
committerScott Parlane <scott.parlane@alliedtelesis.co.nz>
Wed, 2 Sep 2020 05:04:45 +0000 (17:04 +1200)
Seems to appear when stderr is a terminal and not stdin or stdout.

Signed-off-by: Scott Parlane <scott.parlane@alliedtelesis.co.nz>
src/lxc/attach.c

index 4b95989227f4f94fb3f2274773dffaa9d7aa9d89..368dd41ad1a7484fa667801fda84e1ab0dba38d0 100644 (file)
@@ -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);
+                               }
                        }
                }