status-im / nim-protobuf-serialization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RangeDefect on decoding invalid message

arnetheduck opened this issue · comments

echo Protobuf.decode(@[255'u8, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], bool)

this crashes the decoder with a range defect due to usage of a signed integer for header reading:

/home/arnetheduck/status/mite/vendor/nim-protobuf-serialization/protobuf_serialization/reader.nim(243) readValueInternal
/home/arnetheduck/status/mite/vendor/nim-protobuf-serialization/protobuf_serialization/internal.nim(291) readProtobufKey
/home/arnetheduck/status/mite/vendor/nim-protobuf-serialization/protobuf_serialization/numbers/varint.nim(275) decodeVarInt
/home/arnetheduck/status/mite/vendor/nim-protobuf-serialization/protobuf_serialization/numbers/varint.nim(256) decodeVarInt
/home/arnetheduck/status/mite/vendor/nim-protobuf-serialization/protobuf_serialization/numbers/varint.nim(207) decodeBinaryValue
/home/arnetheduck/status/mite/vendor/nimbus-build-system/vendor/Nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: value out of range: 4294967295 notin -2147483648 .. 2147483647 [RangeDefect]