mirror of
https://github.com/curl/curl.git
synced 2026-07-31 21:48:04 +03:00
tool_urlglob: avoid overflow at end of range
Due to how the range span globbing code works, a range that ends with 9223372036854775807 (the maximum signed 63 bit value) cannot be used as it triggers an integer overflow. Verified in test 2092 Reported-by: Andrew Nesbit Closes #21529
This commit is contained in:
parent
9249aad4c2
commit
3ce10063f1
3 changed files with 33 additions and 3 deletions
|
|
@ -324,8 +324,10 @@ static CURLcode glob_range(struct URLGlob *glob, const char **patternp,
|
|||
/* the pattern is not well-formed */
|
||||
return globerror(glob, "bad range", *posp, CURLE_URL_MALFORMAT);
|
||||
|
||||
/* typecasting to ints are fine here since we make sure above that we
|
||||
are within 31 bits */
|
||||
if((CURL_OFF_T_MAX - step_n) < max_n)
|
||||
return globerror(glob, "range end/step overflow", *posp,
|
||||
CURLE_URL_MALFORMAT);
|
||||
|
||||
pat->c.num.idx = pat->c.num.min = min_n;
|
||||
pat->c.num.max = max_n;
|
||||
pat->c.num.step = step_n;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue