From: Ben Harris Date: Thu, 27 Feb 2025 22:48:52 +0000 (+0000) Subject: Handle SOURCE_DATE_EPOCH in unsigned long long, not unitmax_t X-Git-Tag: bedstead-3.252~6 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=528c0542ede8d861ace92ff36c4e66281c405537;p=bedstead.git Handle SOURCE_DATE_EPOCH in unsigned long long, not unitmax_t unsigned long long is guaranteed to be big enough. No need to go bigger. --- diff --git a/bedstead.c b/bedstead.c index fe87a1a..a4f30e4 100644 --- a/bedstead.c +++ b/bedstead.c @@ -99,7 +99,6 @@ #include #include #include -#include #include #include #include @@ -3145,26 +3144,26 @@ static char * time_for_ttx(void) { struct tm *timeptr, tm; - uintmax_t epochumax; + unsigned long long epochull; char *epochstr, *endptr, *timestr; /* Work out what timestamp to use. */ if ((epochstr = getenv("SOURCE_DATE_EPOCH")) != NULL) { errno = 0; - epochumax = strtoumax(epochstr, &endptr, 10); + epochull = strtoull(epochstr, &endptr, 10); if (!isdigit((unsigned char)epochstr[0]) || endptr == epochstr || *endptr != '\0' || errno == ERANGE || /* Allow years up to 9999. */ - epochumax >= 253402300800) { + epochull >= 253402300800) { fprintf(stderr, "Invalid SOURCE_DATE_EPOCH\n"); return NULL; } tm.tm_isdst = -1; - tm.tm_sec = epochumax % 60; - tm.tm_min = epochumax / 60 % 60; - tm.tm_hour = epochumax / 3600 % 24; - long day = epochumax / 86400; + tm.tm_sec = epochull % 60; + tm.tm_min = epochull / 60 % 60; + tm.tm_hour = epochull / 3600 % 24; + long day = epochull / 86400; tm.tm_wday = (day + 4) % 7; /* 1970-01-01 was a Thursday. */ int y = 1970 + (day / 146097) * 400; day = day % 146097;