diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-04-17 02:37:46 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-04-17 02:37:46 +0000 |
commit | e35ac78c49c3bd2aeb871cf1ebee43cf73477c6a (patch) | |
tree | 1a258514223834db1b9cd0cc8741c41b378e50d9 /source3/lib | |
parent | 1416106736adb6190ac788ee27c2a4bf4eb1790f (diff) | |
download | samba-e35ac78c49c3bd2aeb871cf1ebee43cf73477c6a.tar.gz samba-e35ac78c49c3bd2aeb871cf1ebee43cf73477c6a.tar.bz2 samba-e35ac78c49c3bd2aeb871cf1ebee43cf73477c6a.zip |
make suure we get the return value from the pull_*() functions right
for both null terminated and buffer length terminated strings
(This used to be commit e8fbf853e0eed61bb7405be731f18fb2426f8dc4)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/charcnv.c | 18 | ||||
-rw-r--r-- | source3/lib/util_str.c | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index cd32779594..a6db286134 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -356,9 +356,11 @@ int pull_ascii(char *dest, const void *src, int dest_len, int src_len, int flags if (flags & STR_TERMINATE) { if (src_len == -1) { - src_len = strlen(src); + src_len = strlen(src) + 1; } else { - src_len = strnlen(src, src_len); + int len = strnlen(src, src_len); + if (len < src_len) len++; + src_len = len; } } @@ -551,9 +553,11 @@ int pull_ucs2(const void *base_ptr, char *dest, const void *src, int dest_len, i if (flags & STR_TERMINATE) { if (src_len == -1) { - src_len = strlen_w(src)*2; + src_len = strlen_w(src)*2 + 2; } else { - src_len = strnlen_w(src, src_len/2)*2; + int len = strnlen_w(src, src_len/2); + if (len < src_len/2) len++; + src_len = len*2; } } @@ -623,9 +627,11 @@ int pull_utf8(char *dest, const void *src, int dest_len, int src_len, int flags) if (flags & STR_TERMINATE) { if (src_len == -1) { - src_len = strlen(src); + src_len = strlen(src) + 1; } else { - src_len = strnlen(src, src_len); + int len = strnlen(src, src_len); + if (len < src_len) len++; + src_len = len; } } diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 9a841a36b3..f6e579ddba 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1004,7 +1004,7 @@ some platforms don't have strndup #ifndef HAVE_STRNLEN /******************************************************************* -some platforms don't have strndup +some platforms don't have strnlen ********************************************************************/ size_t strnlen(const char *s, size_t n) { |