From: Michal Privoznik Date: Mon, 5 Nov 2012 14:42:53 +0000 (+0100) Subject: iohelper: Don't report errors on special FDs X-Git-Tag: CVE-2012-3411~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46325e51310344872597453ba5d621afa88d44c1;p=thirdparty%2Flibvirt.git iohelper: Don't report errors on special FDs Some FDs may not implement fdatasync() functionality, e.g. pipes. In that case EINVAL or EROFS is returned. We don't want to fail then nor report any error. Reported-by: Christophe Fergeau --- diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 860e14a98f..a9c8b4cefa 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -181,8 +181,11 @@ runIO(const char *path, int fd, int oflags, unsigned long long length) /* Ensure all data is written */ if (fdatasync(fdout) < 0) { - virReportSystemError(errno, _("unable to fsync %s"), fdoutname); - goto cleanup; + if (errno != EINVAL && errno != EROFS) { + /* fdatasync() may fail on some special FDs, e.g. pipes */ + virReportSystemError(errno, _("unable to fsync %s"), fdoutname); + goto cleanup; + } } ret = 0;