Split "clobber" function and variables into its own file before it
authorMartin Pool <mbp@samba.org>
Tue, 18 Mar 2003 07:09:23 +0000 (07:09 +0000)
committerMartin Pool <mbp@samba.org>
Tue, 18 Mar 2003 07:09:23 +0000 (07:09 +0000)
grows too much larger.
(This used to be commit 4bbddbfc6a97ebb11e299aa7bd07ebebeab42c65)

source3/Makefile.in
source3/lib/clobber.c [new file with mode: 0644]
source3/lib/util_str.c

index a2290e8f57181deea1487625c03cc56530a89723..88e616de4793b80f071172bd12d22a19c75e8dee 100644 (file)
@@ -154,7 +154,7 @@ LIB_OBJ = lib/charcnv.o lib/debug.o lib/fault.o \
          lib/util_getent.o lib/util_pw.o lib/access.o lib/smbrun.o \
          lib/bitmap.o lib/crc32.o lib/snprintf.o lib/dprintf.o \
          lib/xfile.o lib/wins_srv.o \
-         lib/util_str.o lib/util_sid.o lib/util_uuid.o \
+         lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \
          lib/util_unistr.o lib/util_file.o lib/data_blob.o \
          lib/util.o lib/util_sock.o lib/util_sec.o \
          lib/talloc.o lib/hash.o lib/substitute.o lib/fsusage.o \
diff --git a/source3/lib/clobber.c b/source3/lib/clobber.c
new file mode 100644 (file)
index 0000000..fb3a0dc
--- /dev/null
@@ -0,0 +1,60 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Martin Pool     2003
+   Copyright (C) Andrew Bartlett 2003
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+#ifdef DEVELOPER
+const char *global_clobber_region_function;
+unsigned int global_clobber_region_line;
+#endif
+
+/**
+ * In developer builds, clobber a region of memory.
+ *
+ * If we think a string buffer is longer than it really is, this ought
+ * to make the failure obvious, by segfaulting (if in the heap) or by
+ * killing the return address (on the stack), or by trapping under a
+ * memory debugger.
+ *
+ * This is meant to catch possible string overflows, even if the
+ * actual string copied is not big enough to cause an overflow.
+ *
+ * In addition, under Valgrind the buffer is marked as uninitialized.
+ **/
+void clobber_region(const char *fn, unsigned int line, char *dest, size_t len)
+{
+#ifdef DEVELOPER
+       global_clobber_region_function = fn;
+       global_clobber_region_line = line;
+
+       /* F1 is odd and 0xf1f1f1f1 shouldn't be a valid pointer */
+       memset(dest, 0xF1, len);
+#ifdef VALGRIND
+       /* Even though we just wrote to this, from the application's
+        * point of view it is not initialized.
+        *
+        * (This is not redundant with the clobbering above.  The
+        * marking might not actually take effect if we're not running
+        * under valgrind.) */
+       VALGRIND_MAKE_WRITABLE(dest, len);
+#endif /* VALGRIND */
+#endif /* DEVELOPER */
+}
index 3836d42872bbfac1935d22478961f7c9078b6d25..8ef4ddade61ee55bcc61e830a2cdc4ff725331ae 100644 (file)
 
 #include "includes.h"
 
-#ifdef DEVELOPER
-const char *global_clobber_region_function;
-unsigned int global_clobber_region_line;
-#endif
-
 /**
  * Get the next token from a string, return False if none found.
  * Handles double-quotes.
@@ -414,40 +409,6 @@ size_t count_chars(const char *s,char c)
        return(count);
 }
 
-/**
- * In developer builds, clobber a region of memory.
- *
- * If we think a string buffer is longer than it really is, this ought
- * to make the failure obvious, by segfaulting (if in the heap) or by
- * killing the return address (on the stack), or by trapping under a
- * memory debugger.
- *
- * This is meant to catch possible string overflows, even if the
- * actual string copied is not big enough to cause an overflow.
- *
- * In addition, under Valgrind the buffer is marked as uninitialized.
- **/
-void clobber_region(const char *fn, unsigned int line, char *dest, size_t len)
-{
-#ifdef DEVELOPER
-       global_clobber_region_function = fn;
-       global_clobber_region_line = line;
-
-       /* F1 is odd and 0xf1f1f1f1 shouldn't be a valid pointer */
-       memset(dest, 0xF1, len);
-#ifdef VALGRIND
-       /* Even though we just wrote to this, from the application's
-        * point of view it is not initialized.
-        *
-        * (This is not redundant with the clobbering above.  The
-        * marking might not actually take effect if we're not running
-        * under valgrind.) */
-       VALGRIND_MAKE_WRITABLE(dest, len);
-#endif /* VALGRIND */
-#endif /* DEVELOPER */
-}
-
-
 /**
  Safe string copy into a known length string. maxlength does not
  include the terminating zero.