Skip to content

Commit 6e19c16

Browse files
Trottdanielleadams
authored andcommitted
tools: update inspector_protocol to a53e96d31a2755eb16ca37
Refs: https://chromium.googlesource.com/deps/inspector_protocol/+log PR-URL: #39694 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 61c53f3 commit 6e19c16

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

tools/inspector_protocol/encoding/encoding.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,12 @@ void CBORTokenizer::ReadNextToken(bool enter_envelope) {
846846
// inspector_protocol, it's not a CBOR limitation); in CBOR, the
847847
// negative values for INT32 are represented as NEGATIVE, that is, -1
848848
// INT32 is represented as 1 << 5 | 0 (major type 1, additional info
849-
// value 0). The minimal allowed INT32 value in our protocol is
850-
// std::numeric_limits<int32_t>::min(). We check for it by directly
851-
// checking the payload against the maximal allowed signed (!) int32
852-
// value.
849+
// value 0).
850+
// The represented allowed values range is -1 to -2^31.
851+
// They are mapped into the encoded range of 0 to 2^31-1.
852+
// We check the the payload in token_start_internal_value_ against
853+
// that range (2^31-1 is also known as
854+
// std::numeric_limits<int32_t>::max()).
853855
if (!success || token_start_internal_value_ >
854856
std::numeric_limits<int32_t>::max()) {
855857
SetError(Error::CBOR_INVALID_INT32);

tools/inspector_protocol/encoding/encoding_test.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ TEST(EncodeDecodeInt32Test, RoundtripsInt32Max) {
235235
}
236236

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

0 commit comments

Comments
 (0)