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

doesn't work since node 6.4 #8

Closed
flroux opened this issue Aug 22, 2016 · 3 comments
Closed

doesn't work since node 6.4 #8

flroux opened this issue Aug 22, 2016 · 3 comments

Comments

@flroux
Copy link

flroux commented Aug 22, 2016

example:

var i3 = require('i3').createClient();

i3.tree((err,tree) => {
    console.log(tree);
});

stdout:

buffer.js:761
        return this.utf8Write(string, offset, length);
                    ^

RangeError: Offset is out of bounds
    at RangeError (native)
    at Buffer.write (buffer.js:761:21)
    at encodeCommand (/home/florian/node_modules/i3/lib/ipc.js:54:7)
    at I3IpcClient.message (/home/florian/node_modules/i3/lib/ipc.js:116:14)
    at I3IpcClient.tree (/home/florian/node_modules/i3/index.js:25:8)
    at Object.<anonymous> (/home/florian/test.js:3:4)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

node version 6.4.0
node-i3 version 0.2.0
i3 version 4.12
work perfecly with node 6.3.1

@sidorares
Copy link
Owner

sidorares commented Aug 22, 2016

Thanks!

I think node 6.4 is more strict about writing zero length string at the end of the buffer ( because length is there there would be no OOB write anyway but check does error earlier )

@sidorares
Copy link
Owner

sidorares commented Aug 22, 2016

This line

buf.write(payload, payloadOffset);

need to be wrapped in something like

if (payload.length > 0) {
  buf.write(payload, payloadOffset);
}

Also need to add changes similar to sidorares/node-mysql2#381
Instead of new Buffer(length) use Buffer.allocUnsafe(length) + add require('safe-buffer') shim for older versions of node

Would you be able to try this yourself and make PR @FlorianLeroux ?

@flroux
Copy link
Author

flroux commented Aug 22, 2016

The fix work
thanks
#9

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

2 participants