Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9cb0633 authored by Myles Watson's avatar Myles Watson
Browse files

PDL: Always compare size to base struct

Fixes: 146523920
Test: bluetooth_test_gd
Change-Id: I08f5023578ab171a99291eee5444d470370e272a
parent 3eaff7ed
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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
+2 −6
Original line number Diff line number Diff line
@@ -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 << "{ 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 << "}";
}