diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2023-05-26 19:34:14 +0300 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2023-05-26 16:12:29 -0400 |
commit | 4653b98711f280270fa049654460610f587ba7b4 (patch) | |
tree | ef549b38dadadcd3417706a438580cbc0030e8f8 | |
parent | b90841e2583237a4132bbbd74752e0e9563660cd (diff) | |
download | musl-4653b98711f280270fa049654460610f587ba7b4.zip musl-4653b98711f280270fa049654460610f587ba7b4.tar.gz musl-4653b98711f280270fa049654460610f587ba7b4.tar.bz2 |
mbrtowc: Fix wrong return value when n > UINT_MAX
mbrtowc truncates n to unsigned int when storing its copy.
If n > UINT_MAX and the locale is not POSIX, the function will
return a wrong value greater than UINT_MAX on the success path.
-rw-r--r-- | src/multibyte/mbrtowc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c index c94819e..7824997 100644 --- a/src/multibyte/mbrtowc.c +++ b/src/multibyte/mbrtowc.c @@ -8,7 +8,7 @@ size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate static unsigned internal_state; unsigned c; const unsigned char *s = (const void *)src; - const unsigned N = n; + const size_t N = n; wchar_t dummy; if (!st) st = (void *)&internal_state; |