ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

msgpack decoder fails with valid msgpack #167

Closed enkore closed 8 years ago

enkore commented 8 years ago

2016/08/19 12:03:01 [pos 11]: readContainerLen: Unrecognized descriptor byte: hex: 13, decimal: 19

File:

00000000  83 a7 63 6f 6d 70 61 63  74 81 13 cc a4 a8 73 65  |..compact.....se|
00000010  67 6d 65 6e 74 73 81 13  01 a7 76 65 72 73 69 6f  |gments....versio|
00000020  6e 02                                             |n.|

Manual decoding:

0x83 = fixmap with three entries 0xa7 = 7 byte fixstr (compact) 0x81 = fixmap with one entry 0x13 (offset 10 / byte no 11) = pos fixint, value = 19, this is the map entry key 0xcc = uint8 0xa4 = value = 164, map entry value

and so on

This works with python-msgpack and probably others.

Issue noticed with msgpack-cli.

ugorji commented 8 years ago

You will need to provide a reproducer, that I can run. It should be a main.go file that I can run with "go run main.go" or a xyz_test.go file that I can run with "go test".

Right now, I can't verify and reproduce, and point to how to fix, etc.

enkore commented 8 years ago

I don't speak go myself, so the best I can do would be this binary file triggering the issue:

167.bin.zip (zipped because GitHub doesn't allow .bin attachments)

What msgpack-python does with it:

>>> import msgpack
>>> msgpack.load(open('167.bin', 'rb'))
{b'version': 2, b'segments': {19: 1}, b'compact': {19: 164}}

And what msgpack-cli based on this library does with it:

$ msgpack-cli decode 167.bin
2016/08/22 20:04:58 [pos 11]: readContainerLen: Unrecognized descriptor byte: hex: 13, decimal: 19
zsh: exit 1     msgpack-cli decode 167.bin

SHA-256:

$ sha256sum 167.bin
f559290e95be95e56ec8f956382d1a29b50b0fd8d4baa806e3b4892a144acefb  167.bin

Hexdump (same as initial post, it's the same file)

00000000  83 a7 63 6f 6d 70 61 63  74 81 13 cc a4 a8 73 65  |..compact.....se|
00000010  67 6d 65 6e 74 73 81 13  01 a7 76 65 72 73 69 6f  |gments....versio|
00000020  6e 02                                             |n.|
00000022
ugorji commented 8 years ago

I don't even know what msgpack-cli is.

Seems like they are the ones that you should contact with a bug report. Maybe they are not using the msgpack library correctly???

enkore commented 8 years ago

I see there are different programs that go by that name. I mean this one: https://github.com/jakm/msgpack-cli

ugorji commented 8 years ago

I will close this bug report now.

This is a bug report for msgpack-cli, not for the library underneath.

If msgpack-cli thinks it is a msgpack library issue, then they can file a report and a representative bug description. Or you can file it directly for this library if you can demonstrate that the problem is with this library, and not with the layer above. For example, msgpack-cli may not have the appropriate options set, etc.

enkore commented 8 years ago

Works for me