Skip to content

Commit

Permalink
file2memory: use a define instead of -1 unsigned value
Browse files Browse the repository at this point in the history
... 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
  • Loading branch information
bagder committed Jul 15, 2020
1 parent 954cd3e commit b331a5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tool_paramhlp.c
Expand Up @@ -115,8 +115,8 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
size_t alloc = 512;
do {
if(!buffer || (alloc == nused)) {
/* size_t overflow detection for huge files */
if(alloc + 1 > ((size_t)-1)/2) {
/* size_t overflow detection and avoiding huge files */
if(alloc >= (SIZE_T_MAX/4)) {
Curl_safefree(buffer);
return PARAM_NO_MEM;
}
Expand Down

0 comments on commit b331a5f

Please sign in to comment.