Skip to content

Commit

Permalink
tools: update inspector_protocol to a53e96d31a2755eb16ca37
Browse files Browse the repository at this point in the history
Refs: https://chromium.googlesource.com/deps/inspector_protocol/+log

PR-URL: #39694
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and targos committed Sep 4, 2021
1 parent ad39687 commit b95a759
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tools/inspector_protocol/encoding/encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,12 @@ void CBORTokenizer::ReadNextToken(bool enter_envelope) {
// inspector_protocol, it's not a CBOR limitation); in CBOR, the
// negative values for INT32 are represented as NEGATIVE, that is, -1
// INT32 is represented as 1 << 5 | 0 (major type 1, additional info
// value 0). The minimal allowed INT32 value in our protocol is
// std::numeric_limits<int32_t>::min(). We check for it by directly
// checking the payload against the maximal allowed signed (!) int32
// value.
// value 0).
// The represented allowed values range is -1 to -2^31.
// They are mapped into the encoded range of 0 to 2^31-1.
// We check the the payload in token_start_internal_value_ against
// that range (2^31-1 is also known as
// std::numeric_limits<int32_t>::max()).
if (!success || token_start_internal_value_ >
std::numeric_limits<int32_t>::max()) {
SetError(Error::CBOR_INVALID_INT32);
Expand Down
7 changes: 6 additions & 1 deletion tools/inspector_protocol/encoding/encoding_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ TEST(EncodeDecodeInt32Test, RoundtripsInt32Max) {
}

TEST(EncodeDecodeInt32Test, RoundtripsInt32Min) {
// std::numeric_limits<int32_t> is encoded as a uint32 after the initial byte.
// std::numeric_limits<int32_t> is encoded as a uint32 (4 unsigned bytes)
// after the initial byte, which effectively carries the sign by
// designating the token as NEGATIVE.
std::vector<uint8_t> encoded;
EncodeInt32(std::numeric_limits<int32_t>::min(), &encoded);
// 1 for initial byte, 4 for the uint32.
Expand All @@ -248,6 +250,9 @@ TEST(EncodeDecodeInt32Test, RoundtripsInt32Min) {
CBORTokenizer tokenizer(SpanFrom(encoded));
EXPECT_EQ(CBORTokenTag::INT32, tokenizer.TokenTag());
EXPECT_EQ(std::numeric_limits<int32_t>::min(), tokenizer.GetInt32());
// It's nice to see how the min int32 value reads in hex:
// That is, -1 minus the unsigned payload (0x7fffffff, see above).
EXPECT_EQ(-0x80000000l, tokenizer.GetInt32());
tokenizer.Next();
EXPECT_EQ(CBORTokenTag::DONE, tokenizer.TokenTag());
}
Expand Down

0 comments on commit b95a759

Please sign in to comment.