creationix / msgpack-js

The msgpack protocol implemented in pure javascript.
http://msgpack.org/
MIT License
253 stars 48 forks source link

msgpack.js -> overSized buffers generate an error, when it (probably) shouldn't #20

Open prochat opened 7 years ago

prochat commented 7 years ago

Line 264: //if (decoder.offset !== buffer.length) throw new Error((buffer.length - deco\ der.offset) + " trailing bytes");

Prevents larger buffer containing a shorter msgpack content to be decoded (I commented it out).

My situation is the following: I use a block Ciphering methods to transmit data (with LoRa). Buffers are then multiple of 16, and my msg has trailing 0. I cannot remove those trailing 0 (it could be part of the msgpacked content). I'm using msgpack.js with node-red-node-msgpack.

A workaround would be to send also mspack length in the message, that would be in contradiction with the "as short as possible" characteristic of msgpack. And I think a msgpack message in a larger buffer has to be considered as valid.

Regards, Ph.R.

creationix commented 7 years ago

Yeah, the check should be optional. Could you propose an option to disable the check.