summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-09-06 09:08:01 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-09-06 14:46:45 +0200
commiteb2a5171dab8f3575b4fed747519111ab74ff7b1 (patch)
treeddd4ab07fccfb012990409eb8e9f3ed4843f0020 /src
parent37fb213a2eab80047014e74b0a1c64e9d4dc68f0 (diff)
downloadcurl-eb2a5171dab8f3575b4fed747519111ab74ff7b1.tar.gz
curl: stop retry if Retry-After: is longer than allowed
If Retry-After: specifies a period that is longer than what fits within --retry-max-time, then stop retrying immediately. Added test 366 to verify. Reported-by: Kari Pahula Fixes #7675 Closes #7676
Diffstat (limited to 'src')
-rw-r--r--src/tool_operate.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 960f3020a..ca53d29f7 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -515,6 +515,21 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
sleeptime = LONG_MAX;
else
sleeptime = (long)retry_after * 1000; /* milliseconds */
+
+ /* if adding retry_after seconds to the process would exceed the
+ maximum time allowed for retrying, then exit the retries right
+ away */
+ if(config->retry_maxtime) {
+ curl_off_t seconds = tvdiff(tvnow(), per->retrystart)/1000;
+
+ if((CURL_OFF_T_MAX - retry_after < seconds) ||
+ (seconds + retry_after > config->retry_maxtime)) {
+ warnf(config->global, "The Retry-After: time would "
+ "make this command line exceed the maximum allowed time "
+ "for retries.");
+ goto noretry;
+ }
+ }
}
}
warnf(config->global, "Problem %s. "
@@ -570,6 +585,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
return CURLE_OK;
}
} /* if retry_numretries */
+ noretry:
if((global->progressmode == CURL_PROGRESS_BAR) &&
per->progressbar.calls)