Skip to content

Commit ee1aff9

Browse files
Fix unordered field numbers inside oneof causing fields to be ignored (nanopb#617)
If the field number of a field outside of oneof falls in between the tag numbers allocated to oneof fields, the outside field can end up ignored by the decoder. Found using oss-fuzz.
1 parent a05fa8b commit ee1aff9

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

pb_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag)
207207
pb_size_t start = iter->index;
208208
uint32_t fieldinfo;
209209

210-
if (tag < iter->tag)
210+
if (tag < iter->tag && PB_HTYPE(iter->type) != PB_HTYPE_ONEOF)
211211
{
212212
/* Fields are in tag number order, so we know that tag is between
213213
* 0 and our start position. Setting index to end forces

tests/fuzztest/regressions.zip

300 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)