Skip to content

Commit

Permalink
mbrtowc: Fix wrong return value when n > UINT_MAX
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alexey Izbyshev authored and richfelker committed May 26, 2023
1 parent b90841e commit 4653b98
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/multibyte/mbrtowc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4653b98

Please sign in to comment.