From: Erik Skultety Date: Tue, 3 Mar 2015 15:57:38 +0000 (+0100) Subject: storage: tweak condition to properly test lseek X-Git-Tag: v1.2.13.1~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ae19e709eb5c4b73e618a7efdd94bd2de5b4686;p=thirdparty%2Flibvirt.git storage: tweak condition to properly test lseek According to the POSIX standard, off_t (returned by lseek) is defined as signed integral type no shorter than int. Because our offset variable is defined as unsigned long long, the original check was passed successfully if UINT64_MAX had been used as offset value, due to implicit conversion. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177219 (cherry picked from commit 3fde7986d6694f122ae919d68ec64eee79bd51db) --- diff --git a/src/fdstream.c b/src/fdstream.c index 5d80fc23fc..b8ea86e435 100644 --- a/src/fdstream.c +++ b/src/fdstream.c @@ -610,7 +610,7 @@ virFDStreamOpenFileInternal(virStreamPtr st, } if (offset && - lseek(fd, offset, SEEK_SET) != offset) { + lseek(fd, offset, SEEK_SET) < 0) { virReportSystemError(errno, _("Unable to seek %s to %llu"), path, offset);