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

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



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


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