From b138d017c70421e9d074096fcc3ac676f7e1c846 Mon Sep 17 00:00:00 2001 From: ShengYi Hung Date: Tue, 3 Nov 2026 16:54:14 +1100 Subject: [PATCH] libc/locale: Check EILSEQ return _citrus_iconv_std_iconv_convert can return EILSEQ without setting invlen. As a result, we should check EILSEQ in the return value or it will incorrectly return -2 Reviewed by: kevans Fixes: e2030ca246a7 ("libc: fix c*rtomb/mbrtoc*") MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D61151 --- lib/libc/locale/mbrtocXX_iconv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h index 35d0fd914b1f..a6286fc3c893 100644 --- a/lib/libc/locale/mbrtocXX_iconv.h +++ b/lib/libc/locale/mbrtocXX_iconv.h @@ -123,7 +123,7 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n, continue; /* Illegal sequence. */ - if (invlen > 0) { + if (invlen > 0 || err == EILSEQ) { cs->srcbuf_len = 0; errno = EILSEQ; return ((size_t)-1);