tool_filetime: accept setting negative filetime

This allows --remote-time to set dates before 1970.

Due to a minor omission in the API, it will still avoid setting the time
if it is indeed exactly epoch 0 (jan 1 1970).

Verified by test 762

Fixes #18424
Reported-by: Terence Eden
Closes #18443
This commit is contained in:
Daniel Stenberg 2025-08-31 23:21:43 +02:00
parent a5798a51f0
commit 54f1ef05d6
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 59 additions and 2 deletions

View file

@ -88,7 +88,7 @@ int getfiletime(const char *filename, curl_off_t *stamp)
#if defined(HAVE_UTIME) || defined(HAVE_UTIMES) || defined(_WIN32)
void setfiletime(curl_off_t filetime, const char *filename)
{
if(filetime >= 0) {
if(filetime) {
/* Windows utime() may attempt to adjust the Unix GMT file time by a daylight
saving time offset and since it is GMT that is bad behavior. When we have
access to a 64-bit type we can bypass utime and set the times directly. */