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/euc.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/euc.c')
-rw-r--r-- | lib/libc/locale/euc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c index 6a75033..b45aaf6 100644 --- a/lib/libc/locale/euc.c +++ b/lib/libc/locale/euc.c @@ -185,8 +185,14 @@ _EUC_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, /* FALLTHROUGH */ case 1: case 0: - while (remain-- > 0) + wc = (unsigned char)*s++; + while (--remain > 0) { + if (*s == '\0') { + errno = EILSEQ; + return ((size_t)-1); + } wc = (wc << 8) | (unsigned char)*s++; + } break; } wc = (wc & ~CEI->mask) | CEI->bits[set]; |