microavia / messgen

MIT License
9 stars 11 forks source link

Can't parse arrays which total size exceeds 65535 bytes #38

Closed Roman- closed 2 years ago

Roman- commented 2 years ago

Parser.h accepts the len argument as uint32_t, but then it passes it to detail::Parser<T>::parse which accepts it as uint16_t:

https://github.com/microavia/messgen/blob/ea975688fae5723e8fe70c80a5f7a9726b1e16ef/port/cpp/messgen/Parser.h#L40 https://github.com/microavia/messgen/blob/ea975688fae5723e8fe70c80a5f7a9726b1e16ef/port/cpp/messgen/Dynamic.h#L57

This implicit type conversion uint32_t->uint16_t causes the bug that's not documented and is very hard to spot without deep debugging.

DrTon commented 2 years ago

This is a bug, after moving from uint16 to uint32 for sizes. Fix please to uint32. Thanks for finding!