cthackers / adm-zip

A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk
MIT License
2.03k stars 375 forks source link

TypeError: "value" argument is out of bounds #222

Open GrayDelacluyse opened 6 years ago

GrayDelacluyse commented 6 years ago

I was receiving an exception when adding certain files.

TypeError: "value" argument is out of bounds at checkInt (buffer.js:1180:11) at Buffer.writeInt32LE (buffer.js:1370:5) at Object.entryHeaderToBinary (.../node_modules/adm-zip/headers/entryHeader.js:217:18) at Object.packHeader (.../node_modules/adm-zip/zipEntry.js:260:39) at .../node_modules/adm-zip/zipFile.js:198:41 at Array.forEach () at Object.compressToBuffer (.../node_modules/adm-zip/zipFile.js:182:23) at Object.writeZip (.../node_modules/adm-zip/adm-zip.js:535:32) at db.bjServicesExport.then.x (.../build/services/TaskProcessorService.js:60:20) at at process._tickCallback (internal/process/next_tick.js:188:7)

Digging into the adm-zip code, I noticed on entryHeaderToBinary in entryHeader.js the following line: data.writeInt32LE(_crc, Constants.CENCRC); This seems inconsistent sine on read _crc is data.readUInt32LE(Constants.CENCRC);

After changing the line to write an Unsigned Int, the problem was fixed.

I have not put in a pull request, because I was curious how I could be the first one to run into this and if I was missing something else.

Thanks!

ransoing commented 6 years ago

I also experienced the same issue, and your fix worked for me as well.

Running 64-bit Windows 10.

fanfeilong commented 6 years ago

I also experienced the same issue, and i back to use adm-zip@0.4.7

Running on CentOS Linux release 7.2.1511 (Core)

Homeroe commented 6 years ago

Can confirm the issue. Couldn't rollback to 0.4.7 because zipped files were zipped as folders instead of files.

GrayDelacluyse solutions worked for me too.

I was compressing CVS files, if anything. Running on Debian 9 and NodeJs 6.12

fanfeilong commented 6 years ago

this issue is also reproduction in:

when install node in mac os by brew install , the node version is latest, which will lead the adm-zip to crash into TypeError: "value" argument is out of bounds.

zekenie commented 6 years ago

We're seeing the same problem on both adm-zip@0.4.7 and 0.4.9 on node 8.11.x. But, when we downgrade to node 8.5.x and adm-zip@0.4.7, the problem is gone

terrisgit commented 6 years ago

This is a show stopper. Any chance of shipping this soon? We are running node 6 and Linux.

jmcollin78 commented 6 years ago

I've make a fork to have a chance to continue with this project. It's available here: https://github.com/jmcollin78/adm-zip and you should install it with: npm install adm-zip-jmcnet It has been made for fixing issue 218 but it seems that it's the same bug origin. Try this and let me know.

musclejack commented 6 years ago

We're seeing the same problem on adm-zip@0.4.7 on electron@^1.7.5