------------------------------------------------------------ revno: 11721 revision-id: squid3@treenet.co.nz-20121130131914-rgpw86kt6rwlvwua parent: squid3@treenet.co.nz-20121130131830-w6wz6rrlwjtyfbcn committer: Amos Jeffries branch nick: 3.2 timestamp: Fri 2012-11-30 06:19:14 -0700 message: 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 ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20121130131914-rgpw86kt6rwlvwua # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: e9075eaab2bdc619e4ba3704931eee41a20daf8d # timestamp: 2012-11-30 13:26:46 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # base_revision_id: squid3@treenet.co.nz-20121130131830-\ # w6wz6rrlwjtyfbcn # # Begin patch === modified file 'tools/squidclient.cc' --- tools/squidclient.cc 2012-10-17 00:12:40 +0000 +++ tools/squidclient.cc 2012-11-30 13:19:14 +0000 @@ -268,13 +268,11 @@ 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': @@ -282,13 +280,11 @@ 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 */ @@ -421,7 +417,9 @@ 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) {