From: Douglas Bagnall Date: Tue, 24 Nov 2015 00:54:09 +0000 (+1300) Subject: CVE-2015-5330: next_codepoint_handle_ext: don't short-circuit UTF16 low bytes X-Git-Tag: samba-4.1.22~12 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=f07626d0297ed6bd21623409e1ea1ae1138d23a8;ds=inline CVE-2015-5330: next_codepoint_handle_ext: don't short-circuit UTF16 low bytes UTF16 contains zero bytes when it is encoding ASCII (for example), so we can't assume the absense of the 0x80 bit means a one byte encoding. No current callers use UTF16. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11599 Signed-off-by: Douglas Bagnall Pair-programmed-with: Andrew Bartlett Reviewed-by: Ralph Boehme --- diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index 542eeae73a5..19d084f3d4a 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -331,7 +331,10 @@ _PUBLIC_ codepoint_t next_codepoint_handle_ext( size_t olen; char *outbuf; - if ((str[0] & 0x80) == 0) { + + if (((str[0] & 0x80) == 0) && (src_charset == CH_DOS || + src_charset == CH_UNIX || + src_charset == CH_UTF8)) { *bytes_consumed = 1; return (codepoint_t)str[0]; }