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

zip seems to decode dos time incorrectly? or not ... #9536

Open
ruslandoga opened this issue Mar 4, 2025 · 0 comments · May be fixed by #9537
Open

zip seems to decode dos time incorrectly? or not ... #9536

ruslandoga opened this issue Mar 4, 2025 · 0 comments · May be fixed by #9537
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@ruslandoga
Copy link
Contributor

ruslandoga commented Mar 4, 2025

👋

I have a Zip with a file dated (according to zipdetails) 'Tue Mar 4 13:20:00 2025', but zip thinks it's {{2025, 3, 4}, {13, 19, 60}} which results in zip:unzip/1 returning {error, badarg}.

I think this might be the offending function:

zip:dos_date_time_to_datetime(23140, 27262) -> {{2025, 3, 4}, {13, 19, 60}}

After #8537 it multiplies Seconds by two. Should it roll over to the next minute if the result is 60 or maybe just cap it at 59?

otp/lib/stdlib/src/zip.erl

Lines 2463 to 2472 in e8473e6

%% convert between erlang datetime and the MSDOS date and time
%% that's stored in the zip archive
%% MSDOS Time MSDOS Date
%% bit 0 - 4 5 - 10 11 - 15 16 - 20 21 - 24 25 - 31
%% value second minute hour day (1 - 31) month (1 - 12) years from 1980
dos_date_time_to_datetime(DosDate, DosTime) ->
<<Hour:5, Min:6, Sec:5>> = <<DosTime:16>>,
<<YearFrom1980:7, Month:4, Day:5>> = <<DosDate:16>>,
{{YearFrom1980+1980, Month, Day},
{Hour, Min, Sec * 2}}.

Or is my Zip just malformed?

@ruslandoga ruslandoga added the bug Issue is reported as a bug label Mar 4, 2025
@ruslandoga ruslandoga linked a pull request Mar 4, 2025 that will close this issue
@garazdawi garazdawi self-assigned this Mar 5, 2025
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants