[lxc-devel] [lxc/master] avoid a NULL pointer dereference in lxc-attach
alliedtelesis on Github
lxc-bot at linuxcontainers.org
Wed Sep 2 05:05:52 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 435 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200901/2d4dcb6a/attachment.bin>
-------------- next part --------------
From d9346e19eb953c9f71d545019fc260da046e910f Mon Sep 17 00:00:00 2001
From: Scott Parlane <scott.parlane at alliedtelesis.co.nz>
Date: Wed, 2 Sep 2020 17:01:11 +1200
Subject: [PATCH] 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 <scott.parlane at alliedtelesis.co.nz>
---
src/lxc/attach.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 4b95989227..368dd41ad1 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);
+ }
}
}
More information about the lxc-devel
mailing list