]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
squidclient: Fix missing error handling on PUT
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 28 Feb 2017 17:20:16 +0000 (06:20 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 28 Feb 2017 17:20:16 +0000 (06:20 +1300)
 Detected by Coverity Scan. Issue 1364710

tools/squidclient/squidclient.cc

index 1b17e12c322debe13323909f37cfaf2eac3f2e57..cfc26568991f4053d56ce0d0ecbde1936b551d46 100644 (file)
@@ -569,8 +569,11 @@ main(int argc, char *argv[])
         if (put_file) {
             debugVerbose(1, "Sending HTTP request payload ...");
             int x;
-            lseek(put_fd, 0, SEEK_SET);
-            while ((x = read(put_fd, buf, sizeof(buf))) > 0) {
+            if ((x = lseek(put_fd, 0, SEEK_SET)) < 0) {
+                int xerrno = errno;
+                std::cerr << "ERROR: lseek: " << xstrerr(xerrno) << std::endl;
+
+            } else while ((x = read(put_fd, buf, sizeof(buf))) > 0) {
 
                 x = Transport::Write(buf, x);