mlot / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

Message with only a oneof contents generates invalid pb_field_t #142

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the generator on the attached .proto file (modified version of the 
oneof.proto test)
2. Run the sample main.cpp

What is the expected output? What do you see instead?
I would expect the message to encode/decode properly. Instead, it seems to 
encode to an empty array (bytes_written is 0 in the ostream). If we then try to 
decode what we encoded (temporarily ignoring the fact that nothing was really 
encoded), I see memory corruption, where msg1 actually is getting modified even 
though I am decoding to msg2. This appears to be because the pb_field_t entries 
generated for OneOfMessage_fields are bogus. In particular, data_offset is some 
large number that ends up causing wrap around when it is used in 
pb_field_iter_begin.

What version of the product are you using? On what operating system?
Saw this in both the git checkout a couple days ago and the latest 0.3.2 
release. Running in Ubuntu 14.04 using gcc 4.8.2.

Please provide any additional information below.
I have the following options enabled:
PB_FIELD_32BIT
PB_NO_PACKED_STRUCTS
PB_BUFFER_ONLY

Original issue reported on code.google.com by sgeren...@gmail.com on 26 Jan 2015 at 10:14

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by Petteri.Aimonen on 27 Jan 2015 at 3:33

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 25b92c5b4e15.

Original comment by Petteri.Aimonen on 27 Jan 2015 at 3:49