summaryrefslogtreecommitdiff
path: root/source3/lib/clobber.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-03-22 15:30:43 +1100
committerAndrew Bartlett <abartlet@samba.org>2011-03-23 12:49:39 +1100
commit1923b78209aaa2aa926dedd19e6c97fb449c48c8 (patch)
tree534acb7efe0910616511dd645b86a4b7cd5422a7 /source3/lib/clobber.c
parentcd4306b01e4097b76777a9a85cc226e8b0e8f613 (diff)
downloadsamba-1923b78209aaa2aa926dedd19e6c97fb449c48c8.tar.gz
samba-1923b78209aaa2aa926dedd19e6c97fb449c48c8.tar.bz2
samba-1923b78209aaa2aa926dedd19e6c97fb449c48c8.zip
s3-lib Remove the clobber_region() code.
This code wrote to the full buffer in fstrcpy(), pstrcpy() and other fixed-length string manipulation functions. The hope of this code was to find out at run time if we were mixing up pstring and fstring etc, and to record where this came from. It has a runtime performance impact (particularly if compiled with --enable-developer). It is being removed because of the complexity it adds, and the distinct lack of bugs that this complexity has been credited in finding. The macro-based compile-time checking of string sizes remains. Andrew Bartlett
Diffstat (limited to 'source3/lib/clobber.c')
-rw-r--r--source3/lib/clobber.c63
1 files changed, 0 insertions, 63 deletions
diff --git a/source3/lib/clobber.c b/source3/lib/clobber.c
deleted file mode 100644
index e77e786fb5..0000000000
--- a/source3/lib/clobber.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- 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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#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.) */
-#if defined(VALGRIND_MAKE_MEM_UNDEFINED)
- VALGRIND_MAKE_MEM_UNDEFINED(dest, len);
-#elif defined(VALGRIND_MAKE_WRITABLE)
- VALGRIND_MAKE_WRITABLE(dest, len);
-#endif
-#endif /* VALGRIND */
-#endif /* DEVELOPER */
-}