Loading system/gd/packet/parser/fields/body_field.h +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class BodyField : public PacketField { void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override; void GenBoundsCheck(std::ostream&, Size, Size, std::string) const override{}; // Body fields can only be dynamically sized. const SizeField* size_field_{nullptr}; }; system/gd/packet/parser/fields/packet_field.cc +11 −0 Original line number Diff line number Diff line Loading @@ -130,3 +130,14 @@ bool PacketField::GenRustNameAndType(std::ostream& s) const { s << GetName() << ": " << param_type; return true; } void PacketField::GenBoundsCheck(std::ostream& s, Size start_offset, Size, std::string context) const { Size size = GetSize(); s << "if bytes.len() < " << start_offset.bytes() + size.bytes() << " {"; s << " return Err(Error::InvalidLengthError{"; s << " obj: \"" << context << "\".to_string(),"; s << " field: \"" << GetName() << "\".to_string(),"; s << " wanted: " << start_offset.bytes() + size.bytes() << ","; s << " got: bytes.len()});"; s << "}"; } system/gd/packet/parser/fields/packet_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,8 @@ class PacketField : public Loggable { virtual void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const = 0; virtual void GenBoundsCheck(std::ostream& s, Size start_offset, Size, std::string) const; virtual bool GetterIsByRef() const { return true; } Loading system/gd/packet/parser/fields/padding_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ class PaddingField : public PacketField { void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override; void GenBoundsCheck(std::ostream&, Size, Size, std::string) const override{}; private: Size size_; }; system/gd/packet/parser/fields/payload_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ class PayloadField : public PacketField { void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override; void GenBoundsCheck(std::ostream&, Size, Size, std::string) const override{}; // Payload fields can only be dynamically sized. const SizeField* size_field_; // Only used if the size of the payload is based on another field. Loading Loading
system/gd/packet/parser/fields/body_field.h +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class BodyField : public PacketField { void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override; void GenBoundsCheck(std::ostream&, Size, Size, std::string) const override{}; // Body fields can only be dynamically sized. const SizeField* size_field_{nullptr}; };
system/gd/packet/parser/fields/packet_field.cc +11 −0 Original line number Diff line number Diff line Loading @@ -130,3 +130,14 @@ bool PacketField::GenRustNameAndType(std::ostream& s) const { s << GetName() << ": " << param_type; return true; } void PacketField::GenBoundsCheck(std::ostream& s, Size start_offset, Size, std::string context) const { Size size = GetSize(); s << "if bytes.len() < " << start_offset.bytes() + size.bytes() << " {"; s << " return Err(Error::InvalidLengthError{"; s << " obj: \"" << context << "\".to_string(),"; s << " field: \"" << GetName() << "\".to_string(),"; s << " wanted: " << start_offset.bytes() + size.bytes() << ","; s << " got: bytes.len()});"; s << "}"; }
system/gd/packet/parser/fields/packet_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,8 @@ class PacketField : public Loggable { virtual void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const = 0; virtual void GenBoundsCheck(std::ostream& s, Size start_offset, Size, std::string) const; virtual bool GetterIsByRef() const { return true; } Loading
system/gd/packet/parser/fields/padding_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ class PaddingField : public PacketField { void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override; void GenBoundsCheck(std::ostream&, Size, Size, std::string) const override{}; private: Size size_; };
system/gd/packet/parser/fields/payload_field.h +2 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ class PayloadField : public PacketField { void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override; void GenBoundsCheck(std::ostream&, Size, Size, std::string) const override{}; // Payload fields can only be dynamically sized. const SizeField* size_field_; // Only used if the size of the payload is based on another field. Loading