summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Sampson <ats@offog.org>2017-08-09 14:11:17 +0100
committerng0 <ng0@infotropique.org>2017-08-22 15:29:51 +0000
commit4ca5087d30c9dfc65018f3e2f3a750416a6ad3ed (patch)
tree4a3dfcf33bdf46519620433855b67391ab05ed22
parent0a0f7761434dcfb53f1b36419b5f2ee9e794b1a5 (diff)
downloadgnurl-4ca5087d30c9dfc65018f3e2f3a750416a6ad3ed.tar.gz
gnurl-4ca5087d30c9dfc65018f3e2f3a750416a6ad3ed.tar.bz2
gnurl-4ca5087d30c9dfc65018f3e2f3a750416a6ad3ed.zip
curl: do bounds check using a double comparison
The fix for this in 8661a0aacc01492e0436275ff36a21734f2541bb wasn't complete: if the parsed number in num is larger than will fit in a long, the conversion is undefined behaviour (causing test1427 to fail for me on IA32 with GCC 7.1, although it passes on AMD64 and ARMv7). Getting rid of the cast means the comparison will be done using doubles. It might make more sense for the max argument to also be a double... Fixes #1750 Closes #1749
-rw-r--r--src/tool_paramhlp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index b9dedc989..85c5e79a7 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -218,7 +218,7 @@ static ParameterError str2double(double *val, const char *str, long max)
num = strtod(str, &endptr);
if(errno == ERANGE)
return PARAM_NUMBER_TOO_LARGE;
- if((long)num > max) {
+ if(num > max) {
/* too large */
return PARAM_NUMBER_TOO_LARGE;
}