summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/charcnv.c18
-rw-r--r--source3/lib/util_str.c2
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)
{