summaryrefslogtreecommitdiff
path: root/source3/lib/charcnv.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-16 12:07:12 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-16 12:07:12 +0000
commitb66932e1a5dc3a368474e6e110c5a88a251465f5 (patch)
tree3c8ed799fc19b11c24e8bdf57ae1b28724db4a23 /source3/lib/charcnv.c
parent02f84c6bd0c06c3dacc93d6413d6645367f42744 (diff)
downloadsamba-b66932e1a5dc3a368474e6e110c5a88a251465f5.tar.gz
samba-b66932e1a5dc3a368474e6e110c5a88a251465f5.tar.bz2
samba-b66932e1a5dc3a368474e6e110c5a88a251465f5.zip
fixed the handling of STR_TERMINATE
(This used to be commit dbc6b137a83cf9fe0558625dd32f92f15296fba6)
Diffstat (limited to 'source3/lib/charcnv.c')
-rw-r--r--source3/lib/charcnv.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index be7701237e..803cda36c8 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -354,7 +354,13 @@ int pull_ascii(char *dest, const void *src, int dest_len, int src_len, int flags
dest_len = sizeof(pstring);
}
- if (src_len == -1 && (flags & STR_TERMINATE)) src_len = strlen(src)+1;
+ if (flags & STR_TERMINATE) {
+ if (src_len == -1) {
+ src_len = strlen(src)+1;
+ } else {
+ src_len = strnlen(src, src_len) + 1;
+ }
+ }
ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len);
@@ -543,7 +549,13 @@ int pull_ucs2(const void *base_ptr, char *dest, const void *src, int dest_len, i
if (src_len > 0) src_len--;
}
- if (src_len == -1 && (flags & STR_TERMINATE)) src_len = strlen_w(src)*2+2;
+ if (flags & STR_TERMINATE) {
+ if (src_len == -1) {
+ src_len = strlen_w(src)*2+2;
+ } else {
+ src_len = strnlen_w(src, src_len/2)*2+2;
+ }
+ }
/* ucs2 is always a multiple of 2 bytes */
src_len &= ~1;
@@ -609,7 +621,13 @@ int pull_utf8(char *dest, const void *src, int dest_len, int src_len, int flags)
dest_len = sizeof(pstring);
}
- if (src_len == -1 && (flags & STR_TERMINATE)) src_len = strlen(src)+1;
+ if (flags & STR_TERMINATE) {
+ if (src_len == -1) {
+ src_len = strlen(src)+1;
+ } else {
+ src_len = strnlen(src, src_len) + 1;
+ }
+ }
ret = convert_string(CH_UTF8, CH_UNIX, src, src_len, dest, dest_len);
if (dest_len) dest[MIN(ret, dest_len-1)] = 0;