You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Entries are written with invalid MS-DOS date 0x0000 ("1980-00-00") #3
toBuffer() writes 0 (0x0000) into the last-mod date fields of both the local file header and the central directory header, which encodes month 0 and day 0 (1980-00-00) instead of a valid MS-DOS date.
// repro.mjs (npm i @aklinker1/zero-zip@1.0.1)import{writeFile}from"node:fs/promises";import{createZip}from"@aklinker1/zero-zip";constzip=createZip();zip.addFile("hello.txt","Hello, world!");awaitwriteFile("example.zip",awaitzip.toBuffer());
Run node repro.mjs and inspect example.zip:
$ unzip -l example.zip
Archive: example.zip
Length Date Time Name
--------- ---------- ----- ----
13 1980-00-00 00:00 hello.txt
--------- -------
13 1 file
$ python3 -c 'import zipfile, datetime; i = zipfile.ZipFile("example.zip").infolist()[0]; print(i.date_time); datetime.datetime(*i.date_time)'
(1980, 0, 0, 0, 0, 0)
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: month must be in 1..12
$ unzip -q example.zip -d out && stat -c "%y %n" out/hello.txt
1979-12-31 00:00:00.000000000 +0000 out/hello.txt
$ python3 -c 'import shutil; shutil.make_archive("rezip", "zip", "out")'
Traceback (most recent call last):
...
ValueError: ZIP does not support timestamps before 1980
7z l leaves the date column blank, and yauzl, jszip, Go archive/zip, and jar decode the timestamp as 1979-11-30. Expected: a valid MS-DOS date (APPNOTE.TXT 4.4.6, where month is 1-12 and day is 1-31), such as the current date/time or 0x0021 (1980-01-01) as a fixed default.
In index.ts, w16(localHeader, 0, 12) and w16(centralHeader, 0, 14) write 0 for the date field (0 is valid for MS-DOS time 00:00:00, whereas the minimum valid MS-DOS date is (1 << 5) | 1 = 0x0021).
Tested on @aklinker1/zero-zip@1.0.1 (npm and JSR) and main (b15b883) with Node.js v26.13.0 on Linux.
Activity