[lxc-devel] [lxd/master] client: Don't crash on missing stdin

stgraber on Github lxc-bot at linuxcontainers.org
Tue Apr 9 02:16:07 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190408/8bea04a8/attachment.bin>
-------------- next part --------------
From 577ee4106d75eac9f58f02013a0cddea5890263c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 8 Apr 2019 22:15:14 -0400
Subject: [PATCH] client: Don't crash on missing stdin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 client/lxd_containers.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/client/lxd_containers.go b/client/lxd_containers.go
index a0668dcee2..9d8dbfd957 100644
--- a/client/lxd_containers.go
+++ b/client/lxd_containers.go
@@ -805,7 +805,9 @@ func (r *ProtocolLXD) ExecContainer(containerName string, exec api.ContainerExec
 				}
 
 				if fds["0"] != "" {
-					args.Stdin.Close()
+					if args.Stdin != nil {
+						args.Stdin.Close()
+					}
 
 					// Empty the stdin channel but don't block on it as
 					// stdin may be stuck in Read()


More information about the lxc-devel mailing list