diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-03-22 15:30:43 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-03-23 12:49:39 +1100 |
commit | 1923b78209aaa2aa926dedd19e6c97fb449c48c8 (patch) | |
tree | 534acb7efe0910616511dd645b86a4b7cd5422a7 /source3/lib/util_str.c | |
parent | cd4306b01e4097b76777a9a85cc226e8b0e8f613 (diff) | |
download | samba-1923b78209aaa2aa926dedd19e6c97fb449c48c8.tar.gz |
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/util_str.c')
-rw-r--r-- | source3/lib/util_str.c | 63 |
1 files changed, 15 insertions, 48 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 6a17297231a..a1dfc707075 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -500,24 +500,16 @@ bool strhaslower(const char *s) include the terminating zero. **/ -char *safe_strcpy_fn(const char *fn, - int line, - char *dest, - const char *src, - size_t maxlength) +char *safe_strcpy_fn(char *dest, + const char *src, + size_t maxlength) { size_t len; if (!dest) { - DEBUG(0,("ERROR: NULL dest in safe_strcpy, " - "called from [%s][%d]\n", fn, line)); - return NULL; + smb_panic("ERROR: NULL dest in safe_strcpy"); } -#ifdef DEVELOPER - clobber_region(fn,line,dest, maxlength+1); -#endif - if (!src) { *dest = 0; return dest; @@ -542,18 +534,14 @@ char *safe_strcpy_fn(const char *fn, Safe string cat into a string. maxlength does not include the terminating zero. **/ -char *safe_strcat_fn(const char *fn, - int line, - char *dest, - const char *src, - size_t maxlength) +char *safe_strcat_fn(char *dest, + const char *src, + size_t maxlength) { size_t src_len, dest_len; if (!dest) { - DEBUG(0,("ERROR: NULL dest in safe_strcat, " - "called from [%s][%d]\n", fn, line)); - return NULL; + smb_panic("ERROR: NULL dest in safe_strcat"); } if (!src) @@ -562,10 +550,6 @@ char *safe_strcat_fn(const char *fn, src_len = strnlen(src, maxlength + 1); dest_len = strnlen(dest, maxlength + 1); -#ifdef DEVELOPER - clobber_region(fn, line, dest + dest_len, maxlength + 1 - dest_len); -#endif - if (src_len + dest_len > maxlength) { DEBUG(0,("ERROR: string overflow by %d " "in safe_strcat [%.50s]\n", @@ -589,23 +573,15 @@ char *safe_strcat_fn(const char *fn, characters. Don't change it ! **/ -char *alpha_strcpy_fn(const char *fn, - int line, - char *dest, - const char *src, - const char *other_safe_chars, - size_t maxlength) +char *alpha_strcpy_fn(char *dest, + const char *src, + const char *other_safe_chars, + size_t maxlength) { size_t len, i; -#ifdef DEVELOPER - clobber_region(fn, line, dest, maxlength); -#endif - if (!dest) { - DEBUG(0,("ERROR: NULL dest in alpha_strcpy, " - "called from [%s][%d]\n", fn, line)); - return NULL; + smb_panic("ERROR: NULL dest in alpha_strcpy"); } if (!src) { @@ -638,18 +614,12 @@ char *alpha_strcpy_fn(const char *fn, Like strncpy but always null terminates. Make sure there is room! The variable n should always be one less than the available size. **/ -char *StrnCpy_fn(const char *fn, int line,char *dest,const char *src,size_t n) +char *StrnCpy_fn(char *dest,const char *src,size_t n) { char *d = dest; -#ifdef DEVELOPER - clobber_region(fn, line, dest, n+1); -#endif - if (!dest) { - DEBUG(0,("ERROR: NULL dest in StrnCpy, " - "called from [%s][%d]\n", fn, line)); - return(NULL); + smb_panic("ERROR: NULL dest in StrnCpy"); } if (!src) { @@ -677,9 +647,6 @@ static char *strncpyn(char *dest, const char *src, size_t n, char c) char *p; size_t str_len; -#ifdef DEVELOPER - clobber_region(dest, n+1); -#endif p = strchr_m(src, c); if (p == NULL) { DEBUG(5, ("strncpyn: separator character (%c) not found\n", c)); |