------------------------------------------------------------ revno: 12404 revision-id: squid3@treenet.co.nz-20121124033934-tcw35w5l2594hpv7 parent: squid3@treenet.co.nz-20121124033847-500j6hsxl9c7xdyc committer: Amos Jeffries branch nick: 3.3 timestamp: Fri 2012-11-23 20:39:34 -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-20121124033934-tcw35w5l2594hpv7 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: f08147e1ed9090e81ab97cea2efa5ae9cf7055ef # timestamp: 2012-11-24 03:43:58 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20121124033847-\ # 500j6hsxl9c7xdyc # # Begin patch === modified file 'tools/squidclient.cc' --- tools/squidclient.cc 2012-10-10 01:51:09 +0000 +++ tools/squidclient.cc 2012-11-24 03:39:34 +0000 @@ -265,13 +265,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': @@ -279,13 +277,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 */ @@ -418,7 +414,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) {