File 10815.patch of Package squid-beta

---------------------
PatchSet 10815 
Date: 2007/05/19 14:51:14
Author: amosjeffries
Branch: HEAD
Tag: (none) 
Log:
Fix old bug: append sometimes does not fully copy a string if \0 exists in source

This bug exists in the basic implementation of strncat(dst,src,len) which will only copy EITHER to len or first \0 character, whichever comes first.
In squid this only occurs only if the string internal buffer is large enough to hold the existing plus the new strings.
The buffer re-allocation code used proper xmemcpy which does not have this limitation.
Have now set both append() branches to use the same copy mechanism.

Members: 
	src/SqString.cc:1.3->1.4 

Index: squid3/src/SqString.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/SqString.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- squid3/src/SqString.cc	19 May 2007 06:31:00 -0000	1.3
+++ squid3/src/SqString.cc	19 May 2007 14:51:14 -0000	1.4
@@ -1,6 +1,6 @@
 
 /*
- * $Id: SqString.cc,v 1.3 2007/05/19 06:31:00 amosjeffries Exp $
+ * $Id: SqString.cc,v 1.4 2007/05/19 14:51:14 amosjeffries Exp $
  *
  * DEBUG: section 67    String
  * AUTHOR: Duane Wessels
@@ -186,7 +186,8 @@
         return;
 
     if (len_ + len < size_) {
-        strncat(buf_, str, len);
+        operator[](len_+len) = '\0';
+        xmemcpy(buf_+len_, str, len);
         len_ += len;
     } else {
         unsigned int ssz = len_ + len;