]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
squidpurge: Polish details of what filename is generated from
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 16 Jan 2013 11:49:51 +0000 (00:49 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 16 Jan 2013 11:49:51 +0000 (00:49 +1300)
* 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

tools/purge/copyout.cc

index 872c8165804e987589b74f951277c35dd4affb9b..8980a7817a232e4c6b4232e724c0f3cc36d2da9f 100644 (file)
@@ -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, "/" );