SOURCE_DATE_EPOCH must be in base 10

This commit is contained in:
Rangi
2026-03-30 21:18:52 -04:00
parent 167a7ee80c
commit 25bf0e9e2c
3 changed files with 20 additions and 3 deletions
+5 -3
View File
@@ -501,9 +501,11 @@ int main(int argc, char *argv[]) {
// https://reproducible-builds.org/docs/source-date-epoch/ // https://reproducible-builds.org/docs/source-date-epoch/
time_t now = time(nullptr); time_t now = time(nullptr);
if (char const *sourceDateEpoch = getenv("SOURCE_DATE_EPOCH"); sourceDateEpoch) { if (char const *sourceDateEpoch = getenv("SOURCE_DATE_EPOCH"); sourceDateEpoch) {
// Use `strtoul`, not `parseWholeNumber`, because SOURCE_DATE_EPOCH does if (std::optional<uint64_t> epoch = parseWholeNumber(sourceDateEpoch, BASE_10); epoch) {
// not conventionally support our custom base prefixes now = static_cast<time_t>(*epoch);
now = static_cast<time_t>(strtoul(sourceDateEpoch, nullptr, 0)); } else {
warnx("Ignoring invalid `SOURCE_DATE_EPOCH` value \"%s\"", sourceDateEpoch);
}
} }
sym_Init(now); sym_Init(now);
+1
View File
@@ -0,0 +1 @@
warning: Ignoring invalid `SOURCE_DATE_EPOCH` value "0x1234"
+14
View File
@@ -161,6 +161,20 @@ done
# These tests do their own thing # These tests do their own thing
i="invalid-source-date-epoch"
RGBASMFLAGS="-Weverything -Bcollapse"
(( tests++ ))
echo "${bold}${green}${i}...${rescolors}${resbold}"
SOURCE_DATE_EPOCH=0x1234 "$RGBASM" $RGBASMFLAGS /dev/null >"$output" 2>"$errput"
tryDiff /dev/null "$output" out
our_rc=$?
tryDiff invalid-source-date-epoch.err "$errput" err
(( our_rc = our_rc || $? ))
(( rc = rc || our_rc ))
if [[ $our_rc -ne 0 ]]; then
(( failed++ ))
fi
evaluateDepTest () { evaluateDepTest () {
i="$1" i="$1"
RGBASMFLAGS="-Weverything -Bcollapse -M -" RGBASMFLAGS="-Weverything -Bcollapse -M -"