Fix potential integer overflow in allocStr
This commit is contained in:
2
indep.c
2
indep.c
@@ -104,6 +104,8 @@ allocStr(const char *s, int len)
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
|
if (len < 0 || len >= STR_SIZE_MAX)
|
||||||
|
len = STR_SIZE_MAX - 1;
|
||||||
ptr = NewAtom_N(char, len + 1);
|
ptr = NewAtom_N(char, len + 1);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
fprintf(stderr, "fm: Can't allocate string. Give me more memory!\n");
|
fprintf(stderr, "fm: Can't allocate string. Give me more memory!\n");
|
||||||
|
Reference in New Issue
Block a user