BishopFox/unredacter

Can't run the test sapmle [Out of range error]

ShaoyuWang1 opened this issue · 16 comments

I have run npm install successfully, but the I cant run the test sample successfully the error is :

Error occurred in handler for 'redact': RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 47100. Received -3968
at boundsError (internal/buffer.js:72:9)
at Buffer.readUInt32BE (internal/buffer.js:295:5)
at Jimp. (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/plugin-crop/dist/index.js:43:37)
at scan (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/utils/dist/index.js:53:9)
at Jimp.scanQuiet (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/core/dist/index.js:1262:32)
at Jimp.cropQuiet (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/plugin-crop/dist/index.js:42:12)
at Jimp. [as crop] (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/core/dist/index.js:1176:23)
at /Users/windsky/Downloads/unredacter-main/dist/main.js:363:47
at step (/Users/windsky/Downloads/unredacter-main/dist/main.js:52:23)
at Object.next (/Users/windsky/Downloads/unredacter-main/dist/main.js:33:53) {
code: 'ERR_OUT_OF_RANGE',
methodName: 'crop',
eventName: 'error'
}

0xced commented

I got almost the same error with a slightly different value for the faulty offset when trying to unredact the sample pixellated secret.png:

Error occurred in handler for 'redact': RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 87804. Received -7040
    at boundsError (internal/buffer.js:77:9)
    at Buffer.readUInt32BE (internal/buffer.js:300:5)
    at Jimp.<anonymous> (~/Projects/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:43:37)
    at scan (~/Projects/unredacter/node_modules/@jimp/utils/dist/index.js:53:9)
    at Jimp.scanQuiet (~/Projects/unredacter/node_modules/@jimp/core/dist/index.js:1262:32)
    at Jimp.cropQuiet (~/Projects/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:42:12)
    at Jimp.<computed> [as crop] (~/Projects/unredacter/node_modules/@jimp/core/dist/index.js:1176:23)
    at ~/Projects/unredacter/dist/main.js:363:47
    at step (~/Projects/unredacter/dist/main.js:52:23)
    at Object.next (~/Projects/unredacter/dist/main.js:33:53) {
  code: 'ERR_OUT_OF_RANGE',
  methodName: 'crop',
  eventName: 'error'
}

Tried on macOS, just like @windskyshaoyu.

$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H1615

me too

Same error for me.
I'm on Linux and followed your installation instructions.
The Current Guess and the Best Guess images are also not able to render. Maybe these problems are somehow connected.
Screenshot_20220223_074016

Added a pull request to fix this issue:
#16

Hi @MKesenheimer I tried your fix, which you have published on MKesenheimer Unfortunately I got nearly the same error as before:

(node:1764) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error occurred in handler for 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-792" is invalid for option "size"
at Function.allocUnsafe (buffer.js:358:3)
at Jimp.cropQuiet (C:\Users\kerci\Downloads\unredacter-main\node_modules@jimp\plugin-crop\dist\index.js:40:27)
at Jimp. [as crop] (C:\Users\kerci\Downloads\unredacter-main\node_modules@jimp\core\dist\index.js:1176:23)
at C:\Users\kerci\Downloads\unredacter-main\dist\main.js:289:47
at step (C:\Users\kerci\Downloads\unredacter-main\dist\main.js:52:23)
at Object.next (C:\Users\kerci\Downloads\unredacter-main\dist\main.js:33:53)
at fulfilled (C:\Users\kerci\Downloads\unredacter-main\dist\main.js:24:58) {
code: 'ERR_INVALID_OPT_VALUE',
methodName: 'crop',
eventName: 'error'
}

I tried it with a Windows 10 machine Build 19044.1566

@ercihan Did you try with the image that comes with the installation or with your own image?
You could try increasing or decreasing the font size and play with the other parameters. I added more global parameters at the top of src/main.ts as well.

9cco commented

Have the same issue on Ubuntu 20.04.4, Node v14.19.0, npm 6.14.16.

When running npm start, the images under 'Current Guess:' and 'Best Guess:' seems to be broken. After clicking on 'Click to Start' getting the error:

npm start

> unredacter@1.0.0 start /<path>/unredacter
> npm run build && electron ./dist/main.js


> unredacter@1.0.0 build /<path>/unredacter
> tsc

(node:3352458) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:3352505) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error occurred in handler for 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-380" is invalid for option "size"
    at Function.allocUnsafe (buffer.js:358:3)
    at Jimp.cropQuiet (/<path>/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:40:27)
    at Jimp.<computed> [as crop] (/<path>/unredacter/node_modules/@jimp/core/dist/index.js:1176:23)
    at /<path>/unredacter/dist/main.js:279:47
    at step (/<path>/unredacter/dist/main.js:52:23)
    at Object.next (/<path>/unredacter/dist/main.js:33:53)
    at fulfilled (/<path>/unredacter/dist/main.js:24:58) {
  code: 'ERR_INVALID_OPT_VALUE',
  methodName: 'crop',
  eventName: 'error'
}

Electron produces the log file:

undefined:1 GET file:///<path>/unredacter/undefined net::ERR_FILE_NOT_FOUND
Image (async)
(anonymous) @ renderer.ts:54
step @ renderer.ts:6
(anonymous) @ renderer.ts:6
(anonymous) @ renderer.ts:6
__awaiter @ renderer.ts:6
gatherResults @ renderer.ts:36
(anonymous) @ renderer.ts:24
postMessage (async)
(anonymous) @ renderer.ts:60
VM55 renderer_init.js:75 Uncaught (in promise) Error: Error invoking remote method 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-380" is invalid for option "size"
    at EventEmitter.o.send.o.invoke (VM55 renderer_init.js:75)
o.send.o.invoke @ VM55 renderer_init.js:75
Promise.then (async)
step @ VM56 preload.js:26
fulfilled @ VM56 preload.js:24
Promise.then (async)
step @ VM56 preload.js:26
fulfilled @ VM56 preload.js:24

The last 3 lines are then repeated several times. Hope this could help figuring out what is wrong.

@9cco Have you tried my pull request?
Also look at this comment: #11 (comment)

9cco commented

@MKesenheimer Yes I tried your pull request now. Unfortunately it is still the same problem. Also tried updating npm to version 8.5.3, but still doesn't work.

Error occurred in handler for 'redact': RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 47100. Received -21376
at boundsError (internal/buffer.js:72:9)
main/node_modules/_@jimp_utils@0.16.1@@jimp/utils/dist/index.js:53:9)
code: 'ERR_OUT_OF_RANGE',
methodName: 'crop',
eventName: 'error'

same error

I dug a little deeper into this and found some items of note.

I dropped a console.log(image.bitmap) here and got the following output with the default images:

{
  width: 800,
  height: 190,
  depth: 8,
  interlace: false,
  palette: false,
  color: true,
  alpha: true,
  bpp: 4,
  colorType: 6,
  data: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ... 607950 more bytes>,
  gamma: 0
}

Now, when I was setting up to depixelate an image from Discord, I used the following html:

<HTML/>
<body style="padding: 8px 0px 0px 8px; background-color:#36393f;">
<span style="padding 0px 0px 0px 0px; color: #dcddde; font-weight: 400; font-family: Whitney,'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 32px; margin: 0;">a</span><span style="padding 0px 0px 0px 0px; margin: 0; color: #0000ff; font-size: 32px; font-weight: 400; font-family: Whitney,'Helvetica Neue',Helvetica,Arial,sans-serif;"></span>
</body>
</HTML>

And got the following image:

{
  width: 800,
  height: 190,
  depth: 8,
  interlace: false,
  palette: false,
  color: true,
  alpha: true,
  bpp: 4,
  colorType: 6,
  data: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 607950 more bytes>,
  gamma: 0
}

Concerningly, this shows that all the bytes are black.

What I suspect is that for whatever reason, the browser is not rendering the page, or is perhaps not rendering the page on time. I checked a variety of different possibilities (font? margin? something else?) but couldn't find the cause. If this was a timing issue, we'd expect to see some inconsistent failures in the base case, but that just doesn't happen. Perhaps someone with more insight on the matter could figure this out, but I'm afraid I just don't have time to at present.

me, too

@MKesenheimer Hi, there. I used your repo which was forked from here, and I used the same width and height (468 * 22) with yours in #11 (comment)
However, got some errors in console:
undefined:1 GET file:///Users/username/Dev/unredacter1/unredacter/undefined net::ERR_FILE_NOT_FOUND
Image (async)
(anonymous) @ renderer.ts:54
step @ renderer.ts:6
(anonymous) @ renderer.ts:6
(anonymous) @ renderer.ts:6
__awaiter @ renderer.ts:6
gatherResults @ renderer.ts:36
(anonymous) @ renderer.ts:24
postMessage (async)
(anonymous) @ renderer.ts:60
VM55 renderer_init.js:75 Uncaught (in promise) Error: Error invoking remote method 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-368" is invalid for option "size"
at EventEmitter.o.send.o.invoke (VM55 renderer_init.js:75)

and got errors in IDE console:
Electron[13527:6416855] Warning: Expected min height of view: (<NSPopoverTouchBarItemButton: 0x7fb1e1ec4180>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
Error occurred in handler for 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-368" is invalid for option "size"
at Function.allocUnsafe (buffer.js:358:3)
at Jimp.cropQuiet (/Users/username/Dev/unredacter1/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:40:27)
at Jimp. [as crop] (/Users/username/Dev/unredacter1/unredacter/node_modules/@jimp/core/dist/index.js:1176:23)
at /Users/username/Dev/unredacter1/unredacter/dist/main.js:289:47
at step (/Users/username/Dev/unredacter1/unredacter/dist/main.js:52:23)
at Object.next (/Users/username/Dev/unredacter1/unredacter/dist/main.js:33:53)
at fulfilled (/Users/username/Dev/unredacter1/unredacter/dist/main.js:24:58) {
code: 'ERR_INVALID_OPT_VALUE',
methodName: 'crop',
eventName: 'error'
}

so, always indicate "to be less than or equal to 30 but got a height of 32.000000" and "The value "-368" is invalid for option "size", have you met this, or do you know how to fix it now?

appreciate it!

Hey,

I am not sure what happens in your case. I'm also not the creator of the project so I do not have all the insights.
You could try to play around with the values of blockSize and fontsize in ./src/main.ts.
Let me know if this helps.

Cheers
Matthias

Hey,

I am not sure what happens in your case. I'm also not the creator of the project so I do not have all the insights. You could try to play around with the values of blockSize and fontsize in ./src/main.ts. Let me know if this helps.

Cheers Matthias

I think this problem somehow happens on macOS, but this project can be smoothly run on Windows (got this answer from some of my friends who run it on their Windows laptops). Not sure this solution is helpful for everyone. Anyways, thanks for @MKesenheimer 's help!