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/charcnv.c | |
parent | cd4306b01e4097b76777a9a85cc226e8b0e8f613 (diff) | |
download | samba-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/charcnv.c')
-rw-r--r-- | source3/lib/charcnv.c | 90 |
1 files changed, 22 insertions, 68 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 5b2149b9c1..1779c4fbf7 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -1297,11 +1297,11 @@ size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_ **/ size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx, - const void *base_ptr, - char **ppdest, - const void *src, - size_t src_len, - int flags) + const void *base_ptr, + char **ppdest, + const void *src, + size_t src_len, + int flags) { char *dest; size_t dest_len; @@ -1476,24 +1476,9 @@ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, is -1 then no maxiumum is used. **/ -size_t push_string_check_fn(const char *function, unsigned int line, - void *dest, const char *src, - size_t dest_len, int flags) +size_t push_string_check_fn(void *dest, const char *src, + size_t dest_len, int flags) { -#ifdef DEVELOPER - /* We really need to zero fill here, not clobber - * region, as we want to ensure that valgrind thinks - * all of the outgoing buffer has been written to - * so a send() or write() won't trap an error. - * JRA. - */ -#if 0 - clobber_region(function, line, dest, dest_len); -#else - memset(dest, '\0', dest_len); -#endif -#endif - if (!(flags & STR_ASCII) && (flags & STR_UNICODE)) { return push_ucs2(NULL, dest, src, dest_len, flags); } @@ -1515,24 +1500,10 @@ size_t push_string_check_fn(const char *function, unsigned int line, is -1 then no maxiumum is used. **/ -size_t push_string_base(const char *function, unsigned int line, - const char *base, uint16 flags2, +size_t push_string_base(const char *base, uint16 flags2, void *dest, const char *src, size_t dest_len, int flags) { -#ifdef DEVELOPER - /* We really need to zero fill here, not clobber - * region, as we want to ensure that valgrind thinks - * all of the outgoing buffer has been written to - * so a send() or write() won't trap an error. - * JRA. - */ -#if 0 - clobber_region(function, line, dest, dest_len); -#else - memset(dest, '\0', dest_len); -#endif -#endif if (!(flags & STR_ASCII) && \ ((flags & STR_UNICODE || \ @@ -1559,15 +1530,6 @@ size_t push_string_base(const char *function, unsigned int line, ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags) { size_t ret; -#ifdef DEVELOPER - /* We really need to zero fill here, not clobber - * region, as we want to ensure that valgrind thinks - * all of the outgoing buffer has been written to - * so a send() or write() won't trap an error. - * JRA. - */ - memset(dest, '\0', dest_len); -#endif if (!(flags & STR_ASCII) && \ (flags & STR_UNICODE)) { @@ -1595,20 +1557,14 @@ ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags) The resulting string in "dest" is always null terminated. **/ -size_t pull_string_fn(const char *function, - unsigned int line, - const void *base_ptr, - uint16 smb_flags2, - char *dest, - const void *src, - size_t dest_len, - size_t src_len, - int flags) +size_t pull_string_fn(const void *base_ptr, + uint16 smb_flags2, + char *dest, + const void *src, + size_t dest_len, + size_t src_len, + int flags) { -#ifdef DEVELOPER - clobber_region(function, line, dest, dest_len); -#endif - if ((base_ptr == NULL) && ((flags & (STR_ASCII|STR_UNICODE)) == 0)) { smb_panic("No base ptr to get flg2 and neither ASCII nor " "UNICODE defined"); @@ -1637,15 +1593,13 @@ size_t pull_string_fn(const char *function, The resulting string in "dest" is always null terminated. **/ -size_t pull_string_talloc_fn(const char *function, - unsigned int line, - TALLOC_CTX *ctx, - const void *base_ptr, - uint16 smb_flags2, - char **ppdest, - const void *src, - size_t src_len, - int flags) +size_t pull_string_talloc(TALLOC_CTX *ctx, + const void *base_ptr, + uint16 smb_flags2, + char **ppdest, + const void *src, + size_t src_len, + int flags) { if ((base_ptr == NULL) && ((flags & (STR_ASCII|STR_UNICODE)) == 0)) { smb_panic("No base ptr to get flg2 and neither ASCII nor " |