From 6b9f82a9f552a92698d15ab605468f757ccbd32c Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 1 Nov 2017 21:52:07 +0100 Subject: [PATCH] network: reap child in all cases Signed-off-by: Christian Brauner --- src/lxc/network.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lxc/network.c b/src/lxc/network.c index c0ca99d40..b4379d0f9 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -2126,13 +2126,13 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna if (bytes < 0) { SYSERROR("Failed to read from pipe file descriptor"); close(pipefd[0]); - return -1; + } else { + buffer[bytes - 1] = '\0'; } - buffer[bytes - 1] = '\0'; ret = wait_for_pid(child); close(pipefd[0]); - if (ret != 0) { + if (ret != 0 || bytes < 0) { ERROR("lxc-user-nic failed to configure requested network: %s", buffer[0] != '\0' ? buffer : "(null)"); return -1; @@ -2267,19 +2267,18 @@ static int lxc_delete_network_unpriv_exec(const char *lxcpath, const char *lxcna if (bytes < 0) { SYSERROR("Failed to read from pipe file descriptor."); close(pipefd[0]); - return -1; + } else { + buffer[bytes - 1] = '\0'; } - buffer[bytes - 1] = '\0'; - if (wait_for_pid(child) != 0) { + ret = wait_for_pid(child); + close(pipefd[0]); + if (ret != 0 || bytes < 0) { ERROR("lxc-user-nic failed to delete requested network: %s", buffer[0] != '\0' ? buffer : "(null)"); - close(pipefd[0]); return -1; } - close(pipefd[0]); - return 0; } -- 2.39.5