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

Commit fc7acdf2 authored by Myles Watson's avatar Myles Watson Committed by android-build-merger
Browse files

Merge "PDL: Constrain Structs with end_index" am: 9e350725 am: 7b2a003f am: f9f8faef

am: f1d8f820

Change-Id: Ic1c96eb94559662ceab6b4fd319ecf745a6293ff
parents a2d82733 f1d8f820
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ void PacketField::GenBounds(std::ostream& s, Size start_offset, Size end_offset,
    }
    }
  } else {
  } else {
    s << "size_t field_end = field_begin + (" << field_size << ") / 8;";
    s << "size_t field_end = field_begin + (" << field_size << ") / 8;";
    s << "if (field_end > end_index) { field_end = end_index; }";
  }
  }
}
}


+0 −1
Original line number Original line Diff line number Diff line
@@ -63,7 +63,6 @@ void StructField::GenGetter(std::ostream& s, Size start_offset, Size end_offset)
  }
  }
  s << "ASSERT(was_validated_);";
  s << "ASSERT(was_validated_);";
  s << "size_t end_index = size();";
  s << "size_t end_index = size();";
  s << "ASSERT(end_index > 0);";
  GenExtractor(s, start_offset, end_offset);
  GenExtractor(s, start_offset, end_offset);


  if (size_ != -1) {
  if (size_ != -1) {
+14 −0
Original line number Original line Diff line number Diff line
@@ -1157,6 +1157,20 @@ DEFINE_AND_INSTANTIATE_ParentTwoReflectionTest(child_two_two_two_, child_two_two
DEFINE_AND_INSTANTIATE_ChildTwoTwoReflectionTest(child_two_two_two_, child_two_two_three_, child_two_two_four_);
DEFINE_AND_INSTANTIATE_ChildTwoTwoReflectionTest(child_two_two_two_, child_two_two_three_, child_two_two_four_);


DEFINE_AND_INSTANTIATE_ChildTwoTwoThreeReflectionTest(child_two_two_three_);
DEFINE_AND_INSTANTIATE_ChildTwoTwoThreeReflectionTest(child_two_two_three_);

std::vector<uint8_t> one_versionless_struct_packet = {0x01};
std::vector<uint8_t> one_versioned_struct_packet = {0x02, 0x03 /* version */, 0x04, 0x05, 0x06};
std::vector<uint8_t> one_version_one_struct_packet = {0x03, 0x01 /* version */, 0x02};
std::vector<uint8_t> one_version_two_struct_packet = {0x03, 0x02 /* version */, 0x03, 0x04};
DEFINE_AND_INSTANTIATE_OneVersionlessStructPacketReflectionTest(one_versionless_struct_packet,
                                                                one_versioned_struct_packet,
                                                                one_version_one_struct_packet,
                                                                one_version_two_struct_packet);
DEFINE_AND_INSTANTIATE_OneVersionedStructPacketReflectionTest(one_versioned_struct_packet,
                                                              one_version_one_struct_packet,
                                                              one_version_two_struct_packet);
DEFINE_AND_INSTANTIATE_OneVersionOneStructPacketReflectionTest(one_version_one_struct_packet);
DEFINE_AND_INSTANTIATE_OneVersionTwoStructPacketReflectionTest(one_version_two_struct_packet);
}  // namespace parser
}  // namespace parser
}  // namespace packet
}  // namespace packet
}  // namespace bluetooth
}  // namespace bluetooth
+23 −0
Original line number Original line Diff line number Diff line
@@ -248,3 +248,26 @@ packet BitFieldArrayPacket {
  _size_(array): 8,
  _size_(array): 8,
  array : BitField[],
  array : BitField[],
}
}

struct VersionlessStruct {
  one_number : 8,
}

packet OneVersionlessStructPacket {
  versionless : VersionlessStruct,
  _payload_,
}

packet OneVersionedStructPacket : OneVersionlessStructPacket {
  version : 8,
  _payload_,
}

packet OneVersionOneStructPacket : OneVersionedStructPacket(version = 0x01) {
  just_one_number : 8,
}

packet OneVersionTwoStructPacket : OneVersionedStructPacket(version = 0x02) {
  one_number : 8,
  another_number : 8,
}