From: Jim Meyering Date: Mon, 1 Feb 2010 21:17:44 +0000 (+0100) Subject: avoid a probable EINVAL from lseek X-Git-Tag: v0.7.6~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9344e6ad1a8389728c81a375f6812c435e5ac71c;p=thirdparty%2Flibvirt.git avoid a probable EINVAL from lseek * src/qemu/qemu_driver.c (qemudLogReadFD): Don't pass a negative offset (from a preceding failed attempt to seek to EOF) to this use of lseek. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 22593bf8ea..676a27bae2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -558,8 +558,8 @@ qemudLogReadFD(virConnectPtr conn, const char* logDir, const char* name, off_t p close(fd); return -1; } - if (lseek(fd, pos, SEEK_SET) < 0) { - virReportSystemError(conn, errno, + if (pos < 0 || lseek(fd, pos, SEEK_SET) < 0) { + virReportSystemError(conn, pos < 0 ? 0 : errno, _("Unable to seek to %lld in %s"), (long long) pos, logfile); close(fd);