diff options
author | tjr <tjr@FreeBSD.org> | 2004-05-11 14:08:22 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-05-11 14:08:22 +0000 |
commit | d79e71957eba7434bb057e5235756d18a94bd663 (patch) | |
tree | 03cb64125465bb96d3274b485308cf88003eb6b2 /lib/libc/locale/gbk.c | |
parent | 492da9f78578904ce7e841d929c057c81f1203a4 (diff) | |
download | FreeBSD-src-d79e71957eba7434bb057e5235756d18a94bd663.zip FreeBSD-src-d79e71957eba7434bb057e5235756d18a94bd663.tar.gz |
In the absence of proper validation, at least check that null bytes
do not appear as anything but the first byte of a multibyte character.
Diffstat (limited to 'lib/libc/locale/gbk.c')
-rw-r--r-- | lib/libc/locale/gbk.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/locale/gbk.c b/lib/libc/locale/gbk.c index fc42c55..3d061f3 100644 --- a/lib/libc/locale/gbk.c +++ b/lib/libc/locale/gbk.c @@ -119,6 +119,10 @@ _GBK_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, if (n == 0 || (size_t)(len = _gbk_check(*s)) > n) /* Incomplete multibyte sequence */ return ((size_t)-2); + if (n == 2 && s[1] == '\0') { + errno = EILSEQ; + return ((size_t)-1); + } wc = 0; i = len; while (i-- > 0) |