From: Daniel P. Berrange Date: Tue, 1 Nov 2011 12:28:26 +0000 (+0000) Subject: Ensure errno is valid when returning from lxcContainerWaitForContinue X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=065ecf5162b3b5699e3f071817d5cf702d5a88c7;p=libvirt.git 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 --- 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; }