]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
avoid a probable EINVAL from lseek
authorJim Meyering <meyering@redhat.com>
Mon, 1 Feb 2010 21:17:44 +0000 (22:17 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 2 Feb 2010 09:35:52 +0000 (10:35 +0100)
* 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.

src/qemu/qemu_driver.c

index 22593bf8ea105250af38973c35e0698a27667651..676a27bae2a0091d2482097275c39af81a71e0c6 100644 (file)
@@ -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);