From f05fb6c56c418449ef70567f9183f83b126726fd Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 8 Mar 2012 11:27:57 +0100 Subject: [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 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/util.c b/src/util/util.c index 548ed1cbea..15e6cfa171 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; }