diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-31 13:42:49 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-31 13:46:18 +0200 |
commit | 44c829ff60f5e56834e5b1650fd27b262f142727 (patch) | |
tree | d76e4d302dabb0f3e37026cb95d830accebf182c /lib/vasnprintf.c | |
parent | a206ccf8db394a262efc175f1962ba3ea64c8b90 (diff) | |
download | gnulib-44c829ff60f5e56834e5b1650fd27b262f142727.tar.gz |
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.
Diffstat (limited to 'lib/vasnprintf.c')
-rw-r--r-- | lib/vasnprintf.c | 8 |
1 files changed, 5 insertions, 3 deletions
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; |