Prevent unintentional integer overflow in Strgrow
Bug-Chromium: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31467
This commit is contained in:
2
Str.c
2
Str.c
@@ -256,7 +256,7 @@ Strgrow(Str x)
|
|||||||
{
|
{
|
||||||
char *old = x->ptr;
|
char *old = x->ptr;
|
||||||
int newlen;
|
int newlen;
|
||||||
newlen = x->area_size * 6 / 5;
|
newlen = x->area_size + x->area_size / 5;
|
||||||
if (newlen == x->area_size)
|
if (newlen == x->area_size)
|
||||||
newlen += 2;
|
newlen += 2;
|
||||||
if (newlen < 0 || newlen > STR_SIZE_MAX) {
|
if (newlen < 0 || newlen > STR_SIZE_MAX) {
|
||||||
|
Reference in New Issue
Block a user