From: Michal Privoznik Date: Thu, 8 Mar 2012 10:27:57 +0000 (+0100) Subject: util: Don't overflow on errno in virFileAccessibleAs X-Git-Tag: v0.9.11-rc1~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f05fb6c56c418449ef70567f9183f83b126726fd;p=thirdparty%2Flibvirt.git 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. --- 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; }