Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file/zip: clamp timestamps to supported range #4451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LiberalArtist
Copy link
Contributor

Previously, timestamps outside the range supported by the Zip format would lead to an error from integer->integer-bytes.

The Info-ZIP zip utility and libarchive (at least as used by Ark) seem to implicitly clamp timestamps this way. Python's zipfile.ZipFile raises an error by default when timestamps are out of range, but it clamps timestamps this way when called with strict_timestamps=False.


This probably needs some tests.

Does it also need a history note?

I could imagine adding a #:strict-timestamps? option, but I think the default should be permissive: Python's strict default seems to be mostly a source of confusing errors. And at that point, it seemed better to hold off on adding a keyword until/unless someone actually wants one.

One way timestamps before 1980 happen is when translating the POSIX time 0 (1970-01-01T00:00:00Z), which is used by some tools that try to normalize extraneous metadata.

Previously, timestamps outside the range supported by the Zip format
would lead to an error from `integer->integer-bytes`.

The Info-ZIP `zip` utility and `libarchive` (at least as used by Ark)
seem to implicitly clamp timestamps this way. Python's `zipfile.ZipFile`
raises an error by default when timestamps are out of range, but it
clamps timestamps this way when called with `strict_timestamps=False`.
@mflatt
Copy link
Member

mflatt commented Oct 9, 2022

I think tests would go in pkgs/racket-test/tests/file, possibly in packers.rkt or possibly a in new file. I'd be inclined to include a history note. Clamping by default and maybe adding #:strict-timestamps? later seems fine to me.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants