summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-07-15 14:04:32 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-07-16 00:34:05 +0200
commitb331a5fa09e15a01b2ee9ce21fe7e46fcc80dcd3 (patch)
tree69d73ab436f5dc26b431966dad5f6c5f508f4e98 /src
parent954cd3eb482a00fda610ca64498d50db2b2e8298 (diff)
downloadcurl-b331a5fa09e15a01b2ee9ce21fe7e46fcc80dcd3.tar.gz
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
Diffstat (limited to 'src')
-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;
}