[PATCH] util: Don't overflow on errno in virFileAccessibleAs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 548ed1c..15e6cfa 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -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;
         }
 
-- 
1.7.8.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]