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

encodePacket throws [OUT_OF_RANGE] error #85

Open
codeit-ninja opened this issue Jun 30, 2021 · 1 comment
Open

encodePacket throws [OUT_OF_RANGE] error #85

codeit-ninja opened this issue Jun 30, 2021 · 1 comment
Labels

Comments

@codeit-ninja
Copy link

My code looks as follow

const packet = createPacket(0, // sequence
    false, // isFromServer
    false, // isResponse
    ['serverInfo'] // words
 );
 const test = encodePacket(packet);

The encodePacket however throws an error

[ERR_OUT_OF_RANGE]: The value of "length" is out of range. It must be >= 0 && <= 15. Received 21
at validateOffset (buffer.js:104)

How can I fix this?

@edvinerikson
Copy link
Owner

Hello,

there is a bug in the code here:
https://github.com/edvinerikson/frostbite-rcon-utils-node/blob/master/src/encoder.js#L28

buf.write('\0', 4 + word.length, buf.length - 4 + word.length, 'binary'); should be replaced with buf.write('\0', 4 + word.length, 'binary');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants