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.
This commit is contained in:
Jim Meyering 2010-02-01 22:17:44 +01:00
parent 33e25a3984
commit 9344e6ad1a

View File

@ -558,8 +558,8 @@ qemudLogReadFD(virConnectPtr conn, const char* logDir, const char* name, off_t p
close(fd); close(fd);
return -1; return -1;
} }
if (lseek(fd, pos, SEEK_SET) < 0) { if (pos < 0 || lseek(fd, pos, SEEK_SET) < 0) {
virReportSystemError(conn, errno, virReportSystemError(conn, pos < 0 ? 0 : errno,
_("Unable to seek to %lld in %s"), _("Unable to seek to %lld in %s"),
(long long) pos, logfile); (long long) pos, logfile);
close(fd); close(fd);