From: David Lawrence Ramsey Date: Thu, 4 Aug 2005 21:38:41 +0000 (+0000) Subject: don't allow entering invalid Unicode in make_mbchar() either X-Git-Tag: v1.3.9~72 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=71dd8c1ca69e35477b7ffeb4247f73c8291138a8;p=nano.git don't allow entering invalid Unicode in make_mbchar() either git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2974 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index a79a4fca..2321bc7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -146,6 +146,10 @@ CVS code - - Treat the Unicode characters D800-DFFF and FFFE-FFFF as invalid, since the C library's multibyte functions don't seem to. (DLR) + make_mbchar() + - Treat the Unicode characters D800-DFFF and FFFE-FFFF as + invalid, since the C library's multibyte functions don't seem + to. (DLR) parse_mbchar() - Remove now-unneeded bad_chr parameter. (DLR) mbstrchr() diff --git a/src/chars.c b/src/chars.c index dff80d84..f21b9d6f 100644 --- a/src/chars.c +++ b/src/chars.c @@ -333,7 +333,10 @@ char *make_mbchar(int chr, int *chr_mb_len) chr_mb = charalloc(MB_CUR_MAX); *chr_mb_len = wctomb(chr_mb, chr); - if (*chr_mb_len < 0) { + /* Unicode D800-DFFF and FFFE-FFFF are invalid, even though + * they're parsed properly. */ + if (*chr_mb_len < 0 || ((0xD800 <= chr && chr <= 0xDFFF) || + (0XFFFE <= chr && chr <= 0xFFFF))) { wctomb(NULL, 0); *chr_mb_len = 0; }