Msgpack: fixstr gets wrong length
schmee opened this issue · 4 comments
What version are you using (fq -v
)?
$ fq -v 0.4.0 (darwin amd64)
How was fq installed?
Homebrew
Can you reproduce the problem using the latest release or master branch?
No changes to the msgpack module since the 0.4 as far as I can tell.
What did you do?
When encoding the string "string of length 19" (which has length 19), it erroneously gets length 3 instead.
string of length 19
in hex = 737472696e67206f66206c656e6774682031390a
fixstr
of length 19 type = 0xb3
(see https://github.com/msgpack/msgpack/blob/master/spec.md#str-format-family)
Command: echo -n 'b3737472696e67206f66206c656e6774682031390a' | xxd -r -p | fq -d msgpack d
What result did you expect?
A fixstr of length 19.
What did you see instead?
A fixstr of length 3.
$ echo -n 'b3737472696e67206f66206c656e6774682031390a' | xxd -r -p | fq -d msgpack d
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13|0123456789abcdef0123|.{}: <stdin> (msgpack)
0x00|b3 |. | type: "fixstr" (0xb3)
0x00|b3 |. | length: 3
0x00| 73 74 72 | str | value: "str"
0x00| 69 6e 67 20 6f 66 20 6c 65 6e 67 74 68 20 31 39| ing of length 19| gap0: raw bits
0x14|0a| |.| |
Thank you for your great work on fq!
Hey, thanks! nice bug report, #635 should fix it
There seems to be an additional 0x0a "\n" at the end of the example case, from echo maybe? i strip it in the test case i added
Thanks for the speedy fix, I rebuilt from master and can confirm that it solves the issue!
There seems to be an additional 0x0a "\n" at the end of the example case, from echo maybe? i strip it in the test case i added
Yup, copy paste issue 👍
Great, was fortunately easy to spot. It also makes me think that i should probably look for more msgpack test vectors
Can't find any official msgpack tests, let me know if you know if there are any. But i generated a bunch of my own instead, so far things seems to be ok