From 44c829ff60f5e56834e5b1650fd27b262f142727 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 31 Mar 2023 13:42:49 +0200 Subject: [PATCH] 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. --- ChangeLog | 6 ++++++ lib/vasnprintf.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) 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; -- 2.39.5