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

Msg pack bin8 wrong format #237

Closed
AdrianTim opened this issue May 8, 2020 · 3 comments
Closed

Msg pack bin8 wrong format #237

AdrianTim opened this issue May 8, 2020 · 3 comments

Comments

@AdrianTim
Copy link

Hello,

The msg pack bin8 implementation does not follow the msg pack standard.
On the page msgpack-standard the bin8 format is flagged with 0xC4, however, in msgpack_detail.hpp, the bin8_cd which stores the bin8 format is initialized as 0xC7.

That flag belongs to a different format, ext8.
It seems that in the implementation the ext family of formats are used for the bin formats.

2020_05_08_17_50_01_msgpack_spec md_at_master_msgpack_msgpack

Because of this error any fields serialized using the bin family with another serializing library will not be decoded by the jsoncons msgpack implementation.

I have tested if changing the flags would work, and by placing the correct flags in the bin family formats in msgpack_detail.hpp the implementation now correctly decodes bin8 fields.

This also means that the ext family of formats is not supported yet.

For instance, the msg pack serialized byte array:
82 a4 74 65 73 74 20 a3 62 69 6e c4 08 00 01 02 03 04 05 06 07
Should be decoded as the following structure:
{'test': 32, 'bin': b'\x00\x01\x02\x03\x04\x05\x06\x07'}
However, since the 0xC4 flag is not present in this msg pack implementation, the bin field is not decoded.

@danielaparker
Copy link
Owner

danielaparker commented May 9, 2020

Yes, it's a bug, thanks for reporting. Fixed on master. bin 8, 16 and 32 are now mapped correctly, and the mapping for the ext formats has been fixed.

For the ext formats, for ext types 0-127, we don't currently have any place in the API for the ext type, so when parsing only the payload is mapped, to byte string, same as bin. Currently there is no way to output ext formats with ext types 0-127.

For ext type -1, timestamp, timestamp 32 is mapped to uint64 (seconds) with semantic_tag timestamp, and timestamps 64 and 96 are mapped to an array of two integers [seconds,nanoseconds] with semantic_tag timestamp.

@AdrianTim
Copy link
Author

Thank you for the quick solution!

@danielaparker
Copy link
Owner

Fixed in v0.151.0

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

No branches or pull requests

2 participants