diff options
author | Stefano Rivera <github@rivera.za.net> | 2024-12-05 23:26:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-05 23:26:58 +0100 |
commit | d500354798beb9bf8341eb8e84e1e2046bbfd21b (patch) | |
tree | 8133714a62c5f1f32797e0a97512d8e82a8a859b /test/units/modules/test_unarchive.py | |
parent | wait_for_connection - test connection=local does not emit warning (#84438) (diff) | |
download | ansible-d500354798beb9bf8341eb8e84e1e2046bbfd21b.tar.xz ansible-d500354798beb9bf8341eb8e84e1e2046bbfd21b.zip |
unarchive: Clamp zip timestamps on 32-bit time_t (#84409)
Clamp zip timestamps to representible values when unpacking zip files on
platforms that use 32-bit time_t (e.g. Debian i386). This is a
non-issue in practice (in 2024), but should allow the test suite to pass
on Debian i386.
We use a round value of 2038-01-01 00:00:00 for simplicity, and to avoid
running into timezone offsets closer to the actual limit.
MR #81520 introduced sanity-checking tests that used dates not
representable with a 32-bit time_t.
Diffstat (limited to '')
-rw-r--r-- | test/units/modules/test_unarchive.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/units/modules/test_unarchive.py b/test/units/modules/test_unarchive.py index 6a2f0d9a67..b1885c2f1c 100644 --- a/test/units/modules/test_unarchive.py +++ b/test/units/modules/test_unarchive.py @@ -14,6 +14,14 @@ def fake_ansible_module(): return FakeAnsibleModule() +def max_zip_timestamp(): + """Return the max clamp value that will be selected.""" + try: + return time.mktime(time.struct_time((2107, 12, 31, 23, 59, 59, 0, 0, 0))) + except OverflowError: + return time.mktime(time.struct_time((2038, 1, 1, 0, 0, 0, 0, 0, 0))) + + class FakeAnsibleModule: def __init__(self): self.params = {} @@ -68,7 +76,7 @@ class TestCaseZipArchive: ), pytest.param( "21081231.000000", - time.mktime(time.struct_time((2107, 12, 31, 23, 59, 59, 0, 0, 0))), + max_zip_timestamp(), id="invalid-year-2108", ), pytest.param( |