summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-07-15 14:04:32 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-07-15 14:04:32 +0200
commit18033bb650fdcbe30eef21ce717ec5de4c418098 (patch)
tree00c4c3667ec84dc9109e2cd37540983136d44e60
parent2f5d0e497e65aefd655a08e5ca96c70cc3123b40 (diff)
downloadcurl-bagder/no-negative-unsigned.tar.gz
file2memory: use a define instead of -1 unsigned valuebagder/no-negative-unsigned
... 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.
-rw-r--r--src/tool_paramhlp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index c375bcc82..e57daa2e1 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -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;
}