]> xenbits.xensource.com Git - libvirt.git/commitdiff
Ensure errno is valid when returning from lxcContainerWaitForContinue
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 1 Nov 2011 12:28:26 +0000 (12:28 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 1 Nov 2011 18:40:37 +0000 (18:40 +0000)
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

index 06ccf7e2dbb22d1f32ce27083a24c6fa1e751ce2..7a3589b5f8bf0e9c451351b818ada94183485c50 100644 (file)
@@ -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;
     }