summaryrefslogtreecommitdiff
path: root/source3/lib/util_unistr.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-09-25 21:26:16 +0000
committerJeremy Allison <jra@samba.org>2003-09-25 21:26:16 +0000
commitd3b9384308e4b5130c9455b853edc4702d7af303 (patch)
tree026331069404a2dfd74d5d1443cf416d9ccaaa09 /source3/lib/util_unistr.c
parent6c623b55bd023d9b2afa6ac3d69d814475a493e4 (diff)
downloadsamba-d3b9384308e4b5130c9455b853edc4702d7af303.tar.gz
samba-d3b9384308e4b5130c9455b853edc4702d7af303.tar.bz2
samba-d3b9384308e4b5130c9455b853edc4702d7af303.zip
Fix for #480. Change the interface for init_unistr2 to not take a length
but a flags field. We were assuming that 2*strlen(mb_string) == length of ucs2-le string. This is not the case. Count it after conversion. Jeremy. (This used to be commit f82c273a42f930c7152cfab84394781744815e0e)
Diffstat (limited to 'source3/lib/util_unistr.c')
-rw-r--r--source3/lib/util_unistr.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index e7c200218e..e90a824395 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -819,22 +819,25 @@ UNISTR2* ucs2_to_unistr2(TALLOC_CTX *ctx, UNISTR2* dst, smb_ucs2_t* src)
{
size_t len;
- if (!src) return NULL;
+ if (!src)
+ return NULL;
len = strlen_w(src);
/* allocate UNISTR2 destination if not given */
if (!dst) {
dst = (UNISTR2*) talloc(ctx, sizeof(UNISTR2));
- if (!dst) return NULL;
+ if (!dst)
+ return NULL;
}
if (!dst->buffer) {
dst->buffer = (uint16*) talloc(ctx, sizeof(uint16) * (len + 1));
- if (!dst->buffer) return NULL;
+ if (!dst->buffer)
+ return NULL;
}
/* set UNISTR2 parameters */
dst->uni_max_len = len + 1;
- dst->undoc = 0;
+ dst->offset = 0;
dst->uni_str_len = len;
/* copy the actual unicode string */
@@ -842,4 +845,3 @@ UNISTR2* ucs2_to_unistr2(TALLOC_CTX *ctx, UNISTR2* dst, smb_ucs2_t* src)
return dst;
}
-