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
Corrupted ZIP being created from simple read then write #555
ADM-ZIP is creating corrupt ZIPs. Originally, I was trying to read the entries of an existing ZIP, edit a few of them, and then export the resulting buffer. That was failing, and managed to trim it down to this MCVE (minus the ZIP data itself):
constadmZip=require('adm-zip');constfs=require('fs/promises');(async()=>{constzipBuffer=awaitfs.readFile('./file.docx');constunzipped1=admZip(zipBuffer);awaitunzipped1.writeZipPromise('./directWrite.zip');// I intended to do some modification hereconstmodifiedBuffer=awaitunzipped1.toBufferPromise();constunzipped2=admZip(modifiedBuffer);for(constentryofunzipped2.getEntries()){console.log('Reading',entry.name);constentryText=entry.getData();// ERROR!}})();
On the ERROR! line, ADM-ZIP is throwing:
Error: ADM-ZIP: No descriptor present
at Object.DESCRIPTOR_NOT_EXIST (node_modules/adm-zip/util/errors.js:56:16)
at crc32OK (node_modules/adm-zip/zipEntry.js:42:36)
at decompress (node_modules/adm-zip/zipEntry.js:121:26)
at Object.getData (node_modules/adm-zip/zipEntry.js:320:24)
And if I try to unzip directWrite.zip, I get an error ("An error occurred while extracting files." in Ubuntu's extractor).
When I run unzip -t directWrite.zip, I get:
Archive: directWrite.zip
testing: _rels/.rels OK
error: invalid zip file with overlapped components (possible zip bomb)
The source ZIP is fine. I've validated that. I also tried processing a simple ZIP that just contains some flat text files instead of a nested DOCX ZIP, and it still failed in the same way.
I ended up using archiver to create the modified ZIP which worked great. It's a shame though, because now I need to use two different libraries just to edit a ZIP!
I was able to reproduce this - it happens for entries that use a data descriptor (general-purpose flag bit 3), which is how many .docx files are written.
A possible fix is up in #564, with a regression test.
@carcigenicate - since the original repro used your own file.docx, could you try the branch from the PR against your actual files and confirm it resolves the corruption on your end? Want to make sure it covers your case before it lands.
Activity
JohnJunior commentedon Jun 28, 2026
I was able to reproduce this - it happens for entries that use a data descriptor (general-purpose flag bit 3), which is how many
.docxfiles are written.A possible fix is up in #564, with a regression test.
@carcigenicate - since the original repro used your own
file.docx, could you try the branch from the PR against your actual files and confirm it resolves the corruption on your end? Want to make sure it covers your case before it lands.Fix corrupted zip when round-tripping entries with a data descriptor (#…
Merge pull request #564 from JohnJunior/fix/issue-555-data-descriptor