From 065ecf5162b3b5699e3f071817d5cf702d5a88c7 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 1 Nov 2011 12:28:26 +0000 Subject: [PATCH] Ensure errno is valid when returning from lxcContainerWaitForContinue Only some of the return paths of lxcContainerWaitForContinue will have set errno. In other paths we need to set it manually to avoid the caller getting a random stale errno value * src/lxc/lxc_container.c: Set errno in lxcContainerWaitForContinue --- src/lxc/lxc_container.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 06ccf7e2db..7a3589b5f8 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -224,8 +224,13 @@ int lxcContainerWaitForContinue(int control) int readLen; readLen = saferead(control, &msg, sizeof(msg)); - if (readLen != sizeof(msg) || - msg != LXC_CONTINUE_MSG) { + if (readLen != sizeof(msg)) { + if (readLen >= 0) + errno = EIO; + return -1; + } + if (msg != LXC_CONTINUE_MSG) { + errno = EINVAL; return -1; } -- GitLab