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

AdmZip#toBuffer() leads to RangeError [ERR_INVALID_OPT_VALUE] #218

Closed
Thorsten-SCE opened this issue Apr 27, 2018 · 9 comments
Closed

AdmZip#toBuffer() leads to RangeError [ERR_INVALID_OPT_VALUE] #218

Thorsten-SCE opened this issue Apr 27, 2018 · 9 comments

Comments

@Thorsten-SCE
Copy link

Thorsten-SCE commented Apr 27, 2018

Hi,

starting with version 0.4.8 I get the following error with AdmZip#toBuffer():

RangeError[ERR_INVALID_OPT_VALUE]: The value "2884517930" is invalid for option "value".

Up to version 0.4.7 it worked excellently. Enclosed a Typescript code snippet.
adm-zip-error.zip

Thank you
Thorsten

@Thorsten-SCE Thorsten-SCE changed the title AdmZip#toBuffer() RangeError [ERR_INVALID_OPT_VALUE]: The value "2884517930" is invalid for option "value" AdmZip#toBuffer() leads to RangeError [ERR_INVALID_OPT_VALUE] Apr 27, 2018
@jeremytm
Copy link

jeremytm commented May 1, 2018

This issue has hit us too.

@jmcollin78
Copy link
Contributor

jmcollin78 commented May 8, 2018

Same with 0.4.9 with different error:

RangeError [ERR_INVALID_OPT_VALUE]: The value "3499350840" is invalid for option "value"
  at checkInt (buffer.js:1275:11)
  at Buffer.writeInt32LE (buffer.js:1474:5)
  at Object.entryHeaderToBinary (/home/vagrant/cld-apps/node_modules/adm-zip/headers/entryHeader.js:216:18)
  at Object.packHeader (/home/vagrant/cld-apps/node_modules/adm-zip/zipEntry.js:260:39)
  at /home/vagrant/cld-apps/node_modules/adm-zip/zipFile.js:198:41
  at Array.forEach (<anonymous>:null:null)
  at Object.compressToBuffer (/home/vagrant/cld-apps/node_modules/adm-zip/zipFile.js:182:23)
  at Object.writeZip (/home/vagrant/cld-apps/node_modules/adm-zip/adm-zip.js:535:32)
  at exports.extractFolderToTemp.then (/datas/cld-apps/packages/system/server/utils/helperZip.js:47:9)
  at _fulfilled (/home/vagrant/cld-apps/node_modules/q/q.js:854:54)
  at self.promiseDispatch.done (/home/vagrant/cld-apps/node_modules/q/q.js:883:30)
  at Promise.promise.promiseDispatch (/home/vagrant/cld-apps/node_modules/q/q.js:816:13)
  at /home/vagrant/cld-apps/node_modules/q/q.js:624:44
  at runSingle (/home/vagrant/cld-apps/node_modules/q/q.js:137:13)
  at flush (/home/vagrant/cld-apps/node_modules/q/q.js:125:13)
  at process._tickCallback (internal/process/next_tick.js:150:11)

Any hints to bypass this ?

@jmcollin78
Copy link
Contributor

Ok, I found a solution (or a workaround ?!)
Just edit the line 216 of headers/entryHeader.js and change to this line:

data.writeUInt32LE(_crc, Constants.CENCRC);

instead of data.writeInt32LE(_crc, Constants.CENCRC);

Notice the U in writeUInt32LE

For me it fixes the bug.
I've got not time to make a PR, but I hope a contributor can push this change quickly.

Jean-marc

@mfrancois
Copy link

Same issue on my project.

@jmcollin78
Copy link
Contributor

hi @mfrancois , did you try the fix explains above ? Did that solve your problem ?

@mfrancois
Copy link

Hi @jmcollin78 ,
I did test it can I wouldn't change the node_module file. Actually I change package from adm-zip to node-archive, another good one.

@jmcollin78
Copy link
Contributor

@mfrancois I understand. I have the idea to switch too, but this module is the only which can zip and unzip. In my case, i need both feature. I will wait a few for contributors before switching ...

jmcollin78 added a commit to jmcollin78/adm-zip that referenced this issue May 11, 2018
Change writeInt32LE to writeUInt32LE as explain in issue cthackers#218
@jmcollin78
Copy link
Contributor

Here you will find a fork that is fixing the issue: https://github.com/jmcollin78/adm-zip

it is published with the following name:

npm install adm-zip-jmcnet

cthackers added a commit that referenced this issue May 12, 2018
Fix issue #218 - urgent merge and release needed please !
@Thorsten-SCE
Copy link
Author

Issue is solved with version 0.4.11

Thanks to all 👍

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

No branches or pull requests

4 participants