diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-04-14 17:23:25 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-04-28 03:24:05 +0200 |
commit | 75d5ba4109801957eef590b601cce61a6e67064f (patch) | |
tree | 33897636244683badc1579dfffd5edfb62d22b8e | |
parent | 240465f96ef6eb44db35d8e62ff79d95c8a256d5 (diff) | |
download | samba-75d5ba4109801957eef590b601cce61a6e67064f.tar.gz samba-75d5ba4109801957eef590b601cce61a6e67064f.tar.bz2 samba-75d5ba4109801957eef590b601cce61a6e67064f.zip |
lib/util/charset Fix string termination conditions for UTF16 strings
This punts partial UTF16 strings to iconv() to deal with, as it's not
a fast path any longer if it's got an odd length.
Andrew Bartlett
Signed-off-by: Andrew Tridgell <tridge@samba.org>
-rw-r--r-- | lib/util/charset/convert_string.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/util/charset/convert_string.c b/lib/util/charset/convert_string.c index e51add2aaf..f1772f448c 100644 --- a/lib/util/charset/convert_string.c +++ b/lib/util/charset/convert_string.c @@ -179,8 +179,8 @@ bool convert_string_error_handle(struct smb_iconv_handle *ic, unsigned char lastp = '\0'; /* If all characters are ascii, fast path here. */ - while (((slen == (size_t)-1) || (slen >= 2)) && dlen) { - if (((lastp = *p) <= 0x7f) && (p[1] == 0)) { + while (((slen == (size_t)-1) || (slen >= 1)) && dlen) { + if (slen >= 2 && ((lastp = *p) <= 0x7f) && (p[1] == 0)) { *q++ = *p; if (slen != (size_t)-1) { slen -= 2; @@ -221,8 +221,8 @@ bool convert_string_error_handle(struct smb_iconv_handle *ic, unsigned char lastp = '\0'; /* If all characters are ascii, fast path here. */ - while (slen && (dlen >= 2)) { - if ((lastp = *p) <= 0x7F) { + while (slen && (dlen >= 1)) { + if (dlen >=2 && (lastp = *p) <= 0x7F) { *q++ = *p++; *q++ = '\0'; if (slen != (size_t)-1) { |