git: 44eaf36072b7 - stable/15 - libc/locale: Check EILSEQ return

From: ShengYi Hung <aokblast_at_FreeBSD.org>
Date: Thu, 05 Nov 2026 23:02:14 UTC
The branch stable/15 has been updated by aokblast:

URL: https://cgit.FreeBSD.org/src/commit/?id=44eaf36072b72e6bd31da1f6559eeb60592697c5

commit 44eaf36072b72e6bd31da1f6559eeb60592697c5
Author:     ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2026-11-03 05:54:14 +0000
Commit:     ShengYi Hung <aokblast@FreeBSD.org>
CommitDate: 2026-11-05 23:02:07 +0000

    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
    
    (cherry picked from commit b138d017c70421e9d074096fcc3ac676f7e1c846)
---
 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);