mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:33:31 +03:00
file2memory: use a define instead of -1 unsigned value
... to use the maximum value for 'size_t' when detecting integer overflow. Changed the limit to max/4 as already that seems unreasonably large. Codacy didn't like the previous approach. Closes #5683
This commit is contained in:
parent
954cd3eb48
commit
b331a5fa09
1 changed files with 2 additions and 2 deletions
|
|
@ -115,8 +115,8 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
|
||||||
size_t alloc = 512;
|
size_t alloc = 512;
|
||||||
do {
|
do {
|
||||||
if(!buffer || (alloc == nused)) {
|
if(!buffer || (alloc == nused)) {
|
||||||
/* size_t overflow detection for huge files */
|
/* size_t overflow detection and avoiding huge files */
|
||||||
if(alloc + 1 > ((size_t)-1)/2) {
|
if(alloc >= (SIZE_T_MAX/4)) {
|
||||||
Curl_safefree(buffer);
|
Curl_safefree(buffer);
|
||||||
return PARAM_NO_MEM;
|
return PARAM_NO_MEM;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue