The new string macros catch a bug at compile that previously only
authorMartin Pool <mbp@samba.org>
Tue, 18 Mar 2003 05:31:52 +0000 (05:31 +0000)
committerMartin Pool <mbp@samba.org>
Tue, 18 Mar 2003 05:31:52 +0000 (05:31 +0000)
trapped at runtime, which is great.  So we have to try a little harder
to provoke an overflow -- which is still caught nicely in developer
mode.

source/torture/t_stringoverflow.c

index b0503adb8fa69fc6e4bd00a120438adbf633debb..ec14d81189ee46f7c821011dd3eda44dcac3f5ce 100644 (file)
@@ -3,6 +3,7 @@
  int main(void)
 {
        fstring dest;
+       char *ptr = dest;
 
        printf("running on valgrind? %d\n", RUNNING_ON_VALGRIND);
 
         * will actually fit, but this is still wrong because you
         * can't pstrcpy into an fstring.  This should trap in a
         * developer build. */
+
+#if 0
+       /* As of CVS 20030318, this will be trapped at compile time! */
        pstrcpy(dest, "hello");
+#endif /* 0 */
+
+       pstrcpy(ptr, "hello!");
 
        return 0;
 }