From: Bruno Haible Date: Fri, 31 Mar 2023 11:42:49 +0000 (+0200) Subject: vasnwprintf: Fix crash upon conversion failure when processing %s. X-Git-Tag: v1.0~1537 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=44c829ff60f5e56834e5b1650fd27b262f142727;p=gnulib.git vasnwprintf: Fix crash upon conversion failure when processing %s. * lib/vasnprintf.c (VASNPRINTF): When processing %s with !has_precision and !has_width, don't call abort() if there is a conversion failure. --- diff --git a/ChangeLog b/ChangeLog index eed2321d8f..b358a707cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-03-31 Bruno Haible + + vasnwprintf: Fix crash upon conversion failure when processing %s. + * lib/vasnprintf.c (VASNPRINTF): When processing %s with !has_precision + and !has_width, don't call abort() if there is a conversion failure. + 2023-03-30 Bruno Haible Avoid test failures on Android. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 83128fd1ea..8ffab85995 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -3099,10 +3099,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # else count = mbtowc (&wc, arg, arg_end - arg); # endif - if (count <= 0) - /* mbrtowc not consistent with mbrlen, or mbtowc - not consistent with mblen. */ + if (count == 0) + /* mbrtowc not consistent with strlen. */ abort (); + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; ENSURE_ALLOCATION (xsum (length, 1)); result[length++] = wc; arg += count;