tafia / quick-protobuf

A rust implementation of protobuf parser
MIT License
452 stars 87 forks source link

Can't deserialize a protobuf message with default values #262

Closed ash-hashtag closed 5 months ago

ash-hashtag commented 5 months ago

I'm trying to parse a protobuf message, generated using protoc

echo "foo:false" | protoc --encode MyMessage MyMessage.proto

nested messages with default values also fail with UnexpectedEndOfBuffer error

echo "foo:{val: false}" | protoc --encode MyNestedMessage MyMessage.proto

but 'foo: true' or 'foo: { val: true }' works fine

I've tried

    let mut reader = BytesReader::from_bytes(bytes);
    reader.read_message::<T>(bytes) // UnexpectedEndOfBuffer

    reader.read_message_by_len::<T>(bytes, bytes.len()) // UnexpectedEndOfBuffer

    T::from_reader(&mut reader, bytes) // UnexpectedEndOfBuffer

    deserialize_from_slice::<T>(bytes) // UnexpectedEndOfBuffer
ash-hashtag commented 5 months ago

foo: false essentially or any message with all default values returns nothing, so a 0 length array, when passed should return the message with default values, but isn't doing so, instead returns UnexpectedEndOfBuffer

ash-hashtag commented 5 months ago

My bad it is the issue of input, the terminating null character is being skipped, it's on me