forked from Telodendria/Telodendria
[MOD] Add basic length checking
This commit is contained in:
parent
2a61df37ad
commit
88c9d10f90
1 changed files with 7 additions and 1 deletions
|
@ -180,7 +180,7 @@ ParseIPv6(char **str, char **out)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
/* We do not have to check whenever the digit here is valid,
|
/* We do not have to check whenever the digit here is valid,
|
||||||
* because it has to be .*/
|
* because it has to be. */
|
||||||
digit = 0;
|
digit = 0;
|
||||||
digits++;
|
digits++;
|
||||||
|
|
||||||
|
@ -196,6 +196,7 @@ ParseIPv6(char **str, char **out)
|
||||||
length += strlen(ipv4);
|
length += strlen(ipv4);
|
||||||
Free(ipv4);
|
Free(ipv4);
|
||||||
c = Iterate(str);
|
c = Iterate(str);
|
||||||
|
filled = 1;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +208,12 @@ end:
|
||||||
}
|
}
|
||||||
|
|
||||||
length = (size_t) (*str - start);
|
length = (size_t) (*str - start);
|
||||||
|
if (length < 4 || length > 47)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
*out = Malloc(length + 1);
|
*out = Malloc(length + 1);
|
||||||
|
memset(*out, '\0', length + 1);
|
||||||
memcpy(*out, start, length);
|
memcpy(*out, start, length);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue