From: Amos Jeffries Date: Wed, 16 Jan 2013 11:49:51 +0000 (+1300) Subject: squidpurge: Polish details of what filename is generated from X-Git-Tag: SQUID_3_4_0_1~370 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc9a7c803499da7842681f661893b92f2c9073d1;p=thirdparty%2Fsquid.git squidpurge: Polish details of what filename is generated from * change strlen(url) to strlen(ptrt) since the string under ptr is being added to filename, not the whole URL. * also add a few extra magic bytes to make it clear that there is space for delimiters and termination bytes. These were previously hidden as extra bytes in the URL prefix length. Should resolve Coverity Scan false positive issue 740414 --- diff --git a/tools/purge/copyout.cc b/tools/purge/copyout.cc index 872c816580..8980a7817a 100644 --- a/tools/purge/copyout.cc +++ b/tools/purge/copyout.cc @@ -131,7 +131,8 @@ copy_out( size_t filesize, size_t metasize, unsigned debug, if ( ptr == 0 || strlen(ptr) < 4 ) return false; // create filename to store contents into - char *filename = new char[ strlen(url) + strlen(copydir) + strlen(index) ]; + // NP: magic extra 5 bytes for the component delimiter and termination octets + char *filename = new char[ strlen(ptr) + strlen(copydir) + strlen(index) +5 ]; assert( filename != 0 ); strcpy( filename, copydir ); strcat( filename, "/" );