summaryrefslogtreecommitdiff
path: root/source3/lib/charcnv.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-17 02:37:46 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-17 02:37:46 +0000
commite35ac78c49c3bd2aeb871cf1ebee43cf73477c6a (patch)
tree1a258514223834db1b9cd0cc8741c41b378e50d9 /source3/lib/charcnv.c
parent1416106736adb6190ac788ee27c2a4bf4eb1790f (diff)
downloadsamba-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/charcnv.c')
-rw-r--r--source3/lib/charcnv.c18
1 files changed, 12 insertions, 6 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;
}
}