diff --git a/BUILD.bazel b/BUILD.bazel index bc587a0b2249..42175b5ed11e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,7 +12,10 @@ load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library licenses(["notice"]) -exports_files(["LICENSE"]) +exports_files([ + "LICENSE", + "PrivacyInfo.xcprivacy", +]) ################################################################################ # Well Known Types Proto Library Rules diff --git a/upb/reflection/field_def.c b/upb/reflection/field_def.c index c18f62184183..9f2775b8699f 100644 --- a/upb/reflection/field_def.c +++ b/upb/reflection/field_def.c @@ -648,7 +648,7 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix, f->full_name); } - if (oneof_index >= upb_MessageDef_OneofCount(m)) { + if (oneof_index < 0 || oneof_index >= upb_MessageDef_OneofCount(m)) { _upb_DefBuilder_Errf(ctx, "oneof_index out of range (%s)", f->full_name); } diff --git a/upb/util/def_to_proto_test.cc b/upb/util/def_to_proto_test.cc index 0c7b2038f4bc..e14b8c4d154d 100644 --- a/upb/util/def_to_proto_test.cc +++ b/upb/util/def_to_proto_test.cc @@ -333,4 +333,15 @@ TEST(FuzzTest, RoundTripDescriptorRegressionOneofSameName) { })pb")); } +TEST(FuzzTest, NegativeOneofIndex) { + RoundTripDescriptor(ParseTextProtoOrDie( + R"pb(file { + message_type { + name: "A" + field { name: "A" number: 0 type_name: "" oneof_index: -1 } + } + } + )pb")); +} + } // namespace upb_test