aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-23 12:31:47 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-04-23 12:31:47 -0400
commit066175ba425a081ab65541c98f7251e00da6be9b (patch)
treebae7c11a89b23063518624338aa5b38cf6ca38b1
parente103dde4164bf4cbe13da0ee7aa3483a65ca27f1 (diff)
downloadstasis-066175ba425a081ab65541c98f7251e00da6be9b.tar.gz
Handle errors in timeout, max_retries, and max_retry_seconds
-rw-r--r--src/lib/core/download.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/core/download.c b/src/lib/core/download.c
index a979781..eb24351 100644
--- a/src/lib/core/download.c
+++ b/src/lib/core/download.c
@@ -20,12 +20,14 @@ long download(char *url, const char *filename, char **errmsg) {
snprintf(user_agent, sizeof(user_agent), "stasis/%s", STASIS_VERSION);
SYSDEBUG("%s", "Setting timeout");
- long timeout = 30L;
+ size_t timeout_default = 30L;
+ size_t timeout = timeout_default;
const char *timeout_str = getenv("STASIS_DOWNLOAD_TIMEOUT");
if (timeout_str) {
- timeout = strtol(timeout_str, NULL, 10);
- if (timeout <= 0L) {
- timeout = 1L;
+ timeout = strtoul(timeout_str, NULL, 10);
+ if (timeout == ULONG_MAX && errno == ERANGE) {
+ SYSERROR("STASIS_DOWNLOAD_TIMEOUT must be a positive integer. Using default (%zu).", timeout);
+ timeout = timeout_default;
}
}