From: Eric Blake Date: Wed, 2 Mar 2011 23:25:57 +0000 (-0700) Subject: util: correct retry path in virFileOperation X-Git-Tag: CVE-2011-1146~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d152f647606a86992b775c4241ba09dce47fd063;p=thirdparty%2Flibvirt.git util: correct retry path in virFileOperation In virFileOperation, the parent does a fallback to a non-fork attempt if it detects that the child returned EACCES. However, the child was calling _exit(-EACCES), which does _not_ appear as EACCES in the parent. * src/util/util.c (virFileOperation): Correctly pass EACCES from child to parent. --- diff --git a/src/util/util.c b/src/util/util.c index bac71c80c2..f41e117d39 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1559,6 +1559,15 @@ parenterror: goto childerror; } childerror: + /* ret tracks -errno on failure, but exit value must be positive. + * If the child exits with EACCES, then the parent tries again. */ + /* XXX This makes assumptions about errno being < 255, which is + * not true on Hurd. */ + ret = -ret; + if ((ret & 0xff) != ret) { + VIR_WARN("unable to pass desired return value %d", ret); + ret = 0xff; + } _exit(ret); }