Repository navigation
gzip: cannot create file if mtime > 2106-02-07T06:28:15 #133998
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on May 14, 2025 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on May 14, 2025 It is consistent with the specification, I am +1 for setting it to
0. This will have to be documented.I'm at the PyCon US sprints right now, and I decided to give this issue a shot. I have made a pull request.
@adang1345 In the future please ask before using someones idea, they may want to open the pr themselves.
@adang1345 , in this case I'd be 108 before this issue could cause any noticeable problems.
Whether I make it that far or not, I think my care levels would be quite low, so feel free to fix this!From the changelog for the GNU gzip 1.9 (2018-01-07):
When converting from system-dependent time_t format to the 32-bit
unsigned MTIME format used in gzip files, if a timestamp does not
fit gzip now substitutes zero instead of the timestamp's low-order
32 bits, as per Internet RFC 1952. When converting from MTIME to
time_t format, if a timestamp does not fit gzip now warns and
substitutes the nearest in-range value instead of crashing or
silently substituting an implementation-defined value (typically,
the timestamp's low-order bits). This affects timestamps before
1970 and after 2106, and timestamps after 2038 on platforms with
32-bit signed time_t. [bug present since the beginning]So replacing the mtime outside of the valid range with 0 looks the most preferable solution.
Reacted by Huw Jones and Stan UlbrychThere is also a similar issue in
tarfile(see_init_write_gz). @adang1345, are you interesting to fix it there?- added3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixes
on May 22, 2026 - added a commit that references this issue
on May 22, 2026 Hi, PR gh-151828 handles the tarfile
_init_write_gzcase Serhiy flagged above. Can someone please take a look when you have time?- added a commit that references this issue
on Oct 5, 2026 - added a commit that references this issue
on Oct 8, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
- StatusShow more project fieldsNo status
Bug report
Bug description:
We had a VM where ntp went very wonky and ended up thinking it was the year 2141!
Trying to write a gzip file with the system clock greater than
2106-02-07T06:28:15results in a struct error because we tried to cram a 64-bit int into a 32 bit field (which won't work).I wouldn't expect the gzip module to explode in this case, I'd expect it to set the
MTIMEto 0.RFC 1952 (if that's at all relevant these days) states
MWE
Only tested this on macOS on 3.13.2, but from a cursory glance, the mtime handling hasn't changed in over a decade.
Proposed Patch
I'd naïvely fix it with this patch
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs