Add comment explaining the -DDEVELOPER safe_strcpy overflow hack.
authorMartin Pool <mbp@samba.org>
Mon, 17 Feb 2003 23:33:55 +0000 (23:33 +0000)
committerMartin Pool <mbp@samba.org>
Mon, 17 Feb 2003 23:33:55 +0000 (23:33 +0000)
(This used to be commit 90e1d8bdfa9ec0a4f3795d9a89db1d2324447b68)

source3/lib/util_str.c

index d4291082da470ad15e9fdeb81ec28e7be14ea0ad..2beb67d825077495e3087be1e2b212f4413d042d 100644 (file)
@@ -443,7 +443,11 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength)
        }
 
 #ifdef DEVELOPER
-       dest[maxlength]='\0';
+       /* We intentionally write out at the extremity of the destination
+        * string.  If the destination is too short (e.g. pstrcpy into mallocd
+        * or fstring) then this should cause an error under a memory
+        * checker. */
+       dest[maxlength] = '\0';
 #endif
 
        if (!src) {