mirror of
https://github.com/opnsense/src.git
synced 2026-04-24 23:57:30 -04:00
Add SIZE_MAX overflow check
This commit is contained in:
parent
d2796d06d3
commit
0100f0ddf7
1 changed files with 2 additions and 0 deletions
|
|
@ -201,6 +201,8 @@ convert(const char *str)
|
|||
|
||||
if ((n = mbstowcs(NULL, str, 0)) == (size_t)-1)
|
||||
return (NULL);
|
||||
if (SIZE_MAX / sizeof(*buf) < n + 1)
|
||||
errx(1, "conversion buffer length overflow");
|
||||
if ((buf = malloc((n + 1) * sizeof(*buf))) == NULL)
|
||||
err(1, "malloc");
|
||||
if (mbstowcs(buf, str, n + 1) != n)
|
||||
|
|
|
|||
Loading…
Reference in a new issue