OSDN Git Service

PDL: Always compare size to base struct
authorMyles Watson <mylesgw@google.com>
Tue, 10 Mar 2020 18:33:32 +0000 (11:33 -0700)
committerMyles Watson <mylesgw@google.com>
Tue, 10 Mar 2020 19:41:13 +0000 (19:41 +0000)
Fixes: 146523920
Test: bluetooth_test_gd
Change-Id: I08f5023578ab171a99291eee5444d470370e272a

gd/l2cap/l2cap_packet_test.cc
gd/packet/parser/struct_def.cc

index 33752e0..7a413f4 100644 (file)
@@ -141,5 +141,15 @@ TEST(L2capFuzzRegressions, ConfigurationRequestFuzz_5747922062802944) {
   RunConfigurationRequestReflectionFuzzTest(bluetooth_gd_fuzz_test_5747922062802944,
                                             sizeof(bluetooth_gd_fuzz_test_5747922062802944));
 }
+
+TEST(L2capFuzzRegressions, ConfigurationRequestFuzz_5202709231697920) {
+  uint8_t bluetooth_gd_fuzz_test_5747922062802944[] = {
+      0x04, 0x01, 0x45, 0x45, 0x05, 0x01, 0x01, 0x45, 0x05, 0x01,
+  };
+
+  RunConfigurationRequestReflectionFuzzTest(bluetooth_gd_fuzz_test_5747922062802944,
+                                            sizeof(bluetooth_gd_fuzz_test_5747922062802944));
+}
+
 }  // namespace l2cap
 }  // namespace bluetooth
index ebd8b45..d4565ba 100644 (file)
@@ -81,11 +81,7 @@ void StructDef::GenParse(std::ostream& s) const {
 
   if (!fields_.HasBody()) {
     s << "size_t end_index = struct_begin_it.NumBytesRemaining();";
-    if (parent_ != nullptr) {
-      s << "if (end_index < " << GetSize().bytes() << " - to_fill->" << parent_->name_ << "::size())";
-    } else {
-      s << "if (end_index < " << GetSize().bytes() << ")";
-    }
+    s << "if (end_index < " << GetSize().bytes() << ")";
     s << "{ return struct_begin_it.Subrange(0,0);}";
   }
 
@@ -127,7 +123,7 @@ void StructDef::GenParse(std::ostream& s) const {
       s << "}";
     }
   }
-  s << "return struct_begin_it + to_fill->" << name_ << "::size();";
+  s << "return struct_begin_it + to_fill->size();";
   s << "}";
 }