From 5e594aeabf331ae0abb380c5fa58e5348b2b0148 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 9 Feb 2025 10:02:10 -0500 Subject: iconv: fix erroneous decoding of some invalid ShiftJIS sequences out-of-range second bytes were not handled, leading to wrong character output rather than a reported encoding error. fix based on bug report by Nick Wellnhofer, submitted in private in case the issue turned out to have security implications. --- src/locale/iconv.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/locale/iconv.c b/src/locale/iconv.c index 7fb2e1ef..9605c8e9 100644 --- a/src/locale/iconv.c +++ b/src/locale/iconv.c @@ -339,6 +339,8 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri } else if (d-159 <= 252-159) { c++; d -= 159; + } else { + goto ilseq; } if (c>=84) goto ilseq; c = jis0208[c][d]; -- cgit v1.2.1