]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Don't overflow on errno in virFileAccessibleAs
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 8 Mar 2012 10:27:57 +0000 (11:27 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 8 Mar 2012 13:38:55 +0000 (14:38 +0100)
If we need to virFork() to check assess() under different
UID+GID we need to translate returned status via WEXITSTATUS().
Otherwise, we may return values greater than 255 which is
obviously wrong.

src/util/util.c

index 548ed1cbea9bc3a9a222cf89a50fdc09850150d8..15e6cfa1717333cdc3f652a3a72b39eddf72df1a 100644 (file)
@@ -724,8 +724,13 @@ virFileAccessibleAs(const char *path, int mode,
                 return -1;
         }
 
+        if (!WIFEXITED(status)) {
+            errno = EINTR;
+            return -1;
+        }
+
         if (status) {
-            errno = status;
+            errno = WEXITSTATUS(status);
             return -1;
         }