clamscan icon indicating copy to clipboard operation
clamscan copied to clipboard

3.8 GB file gives issue - RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range

Open nitinrgoyal opened this issue 4 years ago • 2 comments

Using latest version of clamscan, I am getting the following error when I try to load a 3.8 GB file.

node-clam: Provided stream is readable. node-clam: Attempting to establish socket/TCP connection for "scanStream" node-clam: using local unix domain socket: /var/run/clamav/clamd.ctl internal/buffer.js:69 throw new ERR_OUT_OF_RANGE('value', range, value); ^

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 3875796802 at checkInt (internal/buffer.js:69:11) at writeU_Int32BE (internal/buffer.js:799:3) at Buffer.writeInt32BE (internal/buffer.js:887:10) at NodeClamTransform._transform (/home/repo-l2/Documents/projects/ge-clam/node_modules/clamscan/lib/NodeClamTransform.js:44:14) at NodeClamTransform.Transform._read (internal/streams/transform.js:205:10) at NodeClamTransform.Transform._write (internal/streams/transform.js:193:12) at writeOrBuffer (internal/streams/writable.js:358:12) at NodeClamTransform.Writable.write (internal/streams/writable.js:303:10) at Readable.ondata (internal/streams/readable.js:726:22) at Readable.emit (events.js:375:28) { code: 'ERR_OUT_OF_RANGE' }

nitinrgoyal avatar Nov 10 '21 05:11 nitinrgoyal

It seems like the buffer is filling up faster than it can be offloaded to the downstream target. Can you share the relevant part of your code?

kylefarris avatar Nov 10 '21 14:11 kylefarris

No, it's writeInt32BE function failing in one of these places: https://github.com/kylefarris/clamscan/search?q=writeInt32BE

It cannot process value bigger than 4 bytes signed integer:

⋊> ~ node                                                                                        07:41:17
Welcome to Node.js v16.9.1.
Type ".help" for more information.
> const size = Buffer.alloc(4);
undefined
> size.writeInt32BE(2442710324, 0);
Uncaught:
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2442710324
    at __node_internal_captureLargerStackTrace (node:internal/errors:464:5)
    at new NodeError (node:internal/errors:371:5)
    at checkInt (node:internal/buffer:72:11)
    at writeU_Int32BE (node:internal/buffer:802:3)
    at Buffer.writeInt32BE (node:internal/buffer:890:10) {
  code: 'ERR_OUT_OF_RANGE'
}

project-administrator avatar May 03 '22 12:05 project-administrator