diff options
author | tjr <tjr@FreeBSD.org> | 2004-04-12 13:09:18 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-04-12 13:09:18 +0000 |
commit | 8f8a2ad1798a75c3b861b2592b934371f81e8fe8 (patch) | |
tree | f1d89115cdb1e299060d4ed9c0869147e5323912 /lib/libc/locale/euc.c | |
parent | 006bc4ac4c098febff8ef46213db4475f141fad1 (diff) | |
download | FreeBSD-src-8f8a2ad1798a75c3b861b2592b934371f81e8fe8.zip FreeBSD-src-8f8a2ad1798a75c3b861b2592b934371f81e8fe8.tar.gz |
Perform some basic validation of multibyte conversion state objects.
Diffstat (limited to 'lib/libc/locale/euc.c')
-rw-r--r-- | lib/libc/locale/euc.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c index 92a3d4c..6a75033 100644 --- a/lib/libc/locale/euc.c +++ b/lib/libc/locale/euc.c @@ -154,6 +154,11 @@ _EUC_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, es = (_EucState *)ps; + if (es->count < 0 || es->count > sizeof(es->bytes)) { + errno = EINVAL; + return ((size_t)-1); + } + if (s == NULL) { s = ""; n = 1; @@ -192,12 +197,19 @@ _EUC_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, } size_t -_EUC_wcrtomb(char * __restrict s, wchar_t wc, - mbstate_t * __restrict ps __unused) +_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) { + _EucState *es; wchar_t m, nm; int i, len; + es = (_EucState *)ps; + + if (es->count != 0) { + errno = EINVAL; + return ((size_t)-1); + } + if (s == NULL) /* Reset to initial shift state (no-op) */ return (1); |