From: Amos Jeffries Date: Thu, 2 Mar 2017 14:44:26 +0000 (+1300) Subject: squidclient: Fix missing error handling on PUT X-Git-Tag: SQUID_4_0_19~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93120b8d0b0ecaa3dee1ecdcdf4cfaddaff998e1;p=thirdparty%2Fsquid.git squidclient: Fix missing error handling on PUT Detected by Coverity Scan. Issue 1364710 --- diff --git a/tools/squidclient/squidclient.cc b/tools/squidclient/squidclient.cc index 1b17e12c32..7b821d848d 100644 --- a/tools/squidclient/squidclient.cc +++ b/tools/squidclient/squidclient.cc @@ -569,16 +569,19 @@ 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; - x = Transport::Write(buf, x); + } else while ((x = read(put_fd, buf, sizeof(buf))) > 0) { - total_bytes += x; + x = Transport::Write(buf, x); - if (x <= 0) - break; - } + total_bytes += x; + + if (x <= 0) + break; + } if (x != 0) std::cerr << "ERROR: Cannot send file." << std::endl;