From: Amos Jeffries Date: Sat, 24 Nov 2012 03:39:34 +0000 (-0700) Subject: squidclient: Better error checking X-Git-Tag: SQUID_3_3_0_2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fda6b13684f14c492ebad52cc77d1563ea4028bd;p=thirdparty%2Fsquid.git squidclient: Better error checking * detect and report fstat() errors which could lead to invalid Content-Length being sent. * remove some useless checks which were causing false positives by Coverity. Detected by Coverity Scan. Issues 740334, 740379 --- diff --git a/tools/squidclient.cc b/tools/squidclient.cc index c6d937cdb0..1c75587051 100644 --- a/tools/squidclient.cc +++ b/tools/squidclient.cc @@ -265,13 +265,11 @@ main(int argc, char *argv[]) break; case 'A': - if (optarg != NULL) - useragent = optarg; + useragent = optarg; break; case 'h': /* remote host */ - if (optarg != NULL) - hostname = optarg; + hostname = optarg; break; case 'j': @@ -279,13 +277,11 @@ main(int argc, char *argv[]) break; case 'V': - if (optarg != NULL) - version = optarg; + version = optarg; break; case 'l': /* local host */ - if (optarg != NULL) - localhost = optarg; + localhost = optarg; break; case 's': /* silent */ @@ -418,7 +414,9 @@ main(int argc, char *argv[]) setmode(put_fd, O_BINARY); #endif - fstat(put_fd, &sb); + if (fstat(put_fd, &sb) < 0) { + fprintf(stderr, "%s: can't identify length of file (%s)\n", argv[0], xstrerror()); + } } if (!host) {