Skip to content

Commit

Permalink
Fixed a bug in MiniTable construction for extensions. #fuzzing
Browse files Browse the repository at this point in the history
We were failing to assign the f->presence field, which resulted in a read of uninitialized memory.

PiperOrigin-RevId: 462138061
  • Loading branch information
haberman authored and copybara-github committed Jul 20, 2022
1 parent ececc21 commit fcb5ef3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions upb/mini_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ const char* upb_MiniTable_BuildExtension(const char* data, size_t len,
upb_MtDecoder_Parse(&decoder, data, len, ext, sizeof(*ext), &count, NULL);
ext->field.mode |= kUpb_LabelFlags_IsExtension;
ext->field.offset = 0;
ext->field.presence = 0;
return ret;
}

Expand Down
11 changes: 10 additions & 1 deletion upb/msg_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ TEST(MessageTest, MapField) {
// }
// FUZZ_TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayload);
//
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegression) {
// TEST(FuzzTest, DecodeUnknownProto2EnumExtension) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\256\354Rt\216\3271\234", "\243\243\267\207\336gV\366w"},
// {"z"},
Expand All @@ -525,4 +525,13 @@ TEST(MessageTest, MapField) {
// "\010", -724543908, -591643538);
// }
//
// TEST(FuzzTest, DecodeExtensionEnsurePresenceInitialized) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\031", "S", "\364", "", "", "j", "\303", "", "\224", "\277"},
// {},
// "_C-\236$*)C0C>",
// {4041515984, 2147483647, 1929379871, 0, 3715937258, 4294967295}},
// "\010\002", 342248070, -806315555);
// }
//
// end:google_only

0 comments on commit fcb5ef3

Please sign in to comment.