]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Fix Y2038 check 1644/head
authorGraham Percival <gperciva@tarsnap.com>
Wed, 22 Dec 2021 02:00:19 +0000 (18:00 -0800)
committerGraham Percival <gperciva@tarsnap.com>
Wed, 22 Dec 2021 02:00:19 +0000 (18:00 -0800)
commit2ab44179ee507842310846644fa76bd5ac4212c4
treebe456d4734b5087cd03887642eef8342e1ce1c22
parent411284e3f5819a5726622f3f129ebf2859f2d46b
Fix Y2038 check

If time_t is a signed 32-bit integer, then we cannot represent times
after 03:14:07 on 2038-01-19.  Indicating an error if (Year > 2038) is
not sufficient; for safety, we need to bail if (Year >= 2038).

As the comment above this line notes, it would be better to check if
time_t is 32 bits first.  And even if we didn't check for that, we could
use a much more complicated check:

    ((Year > 2038) || ((Year == 2038) && (Month > 1)) ||
    ((Year == 2038) && (Month == 1) && (Day >= 19)))

But I don't think the additional complexity is worth it; rejecting any
dates in 2038 eliminates fewer than 3 weeks of potentially-valid dates.

Reported by: Rasmus Villemoes
libarchive/archive_getdate.c