From c4e3a38ee0dde49fb625c75ab95b233ca685ec56 Mon Sep 17 00:00:00 2001 From: Michal Fox Date: Mon, 12 Oct 2026 19:28:28 +0200 Subject: [PATCH] Compute the year-ahead sqv policy date with a calendar On 29 February the year-ahead date was 29 February of a year without one, which sqv rejects as a malformed timestamp, so every repository got a "Policy will reject signature within a year" warning that day. Fall back to the last day of February instead. Closes: #1150291 --- methods/sqv.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/methods/sqv.cc b/methods/sqv.cc index ac73673..7ce3ab1 100644 --- a/methods/sqv.cc +++ b/methods/sqv.cc @@ -3,6 +3,7 @@ #include "aptmethod.h" #include #include +#include #include #include #include @@ -228,8 +229,13 @@ bool SQVMethod::VerifyGetSigners(const char *file, const char *outfile, _error->PushToStack(); auto time = std::time(nullptr); auto tm = std::localtime(&time); + using namespace std::chrono; + auto yearAhead = year_month_day{year{tm->tm_year + 1900}, month(tm->tm_mon + 1), day(tm->tm_mday)} + years{1}; + // 29 February has no counterpart in the next year + if (not yearAhead.ok()) + yearAhead = year_month_day_last{yearAhead.year(), month_day_last{yearAhead.month()}}; std::string yearAheadDate; - strprintf(yearAheadDate, "%d-%d-%d", tm->tm_year + 1900 + 1, tm->tm_mon + 1, tm->tm_mday); + strprintf(yearAheadDate, "%d-%u-%u", int(yearAhead.year()), unsigned(yearAhead.month()), unsigned(yearAhead.day())); args.push_back("--policy-as-of"); args.push_back(std::move(yearAheadDate));