[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
vasnwprintf: Fix crash upon conversion failure when processing %s
From: |
Bruno Haible |
Subject: |
vasnwprintf: Fix crash upon conversion failure when processing %s |
Date: |
Fri, 31 Mar 2023 13:47:16 +0200 |
This patch fixes a crash (abort) during the %s processing in vasnwprintf.
2023-03-31 Bruno Haible <bruno@clisp.org>
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/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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- vasnwprintf: Fix crash upon conversion failure when processing %s,
Bruno Haible <=