Skip to content

Commit 501482c

Browse files
cjihrigCommit Bot
authored andcommitted
Fix ValueDeserializer::ReadDouble() bounds check
If end_ is smaller than sizeof(double), the result would wrap around, and lead to an invalid memory access. Refs: nodejs/node#37978 Change-Id: Ibc8ddcb0c090358789a6a02f550538f91d431c1d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2801353 Reviewed-by: Marja Hölttä <[email protected]> Commit-Queue: Marja Hölttä <[email protected]> Cr-Commit-Position: refs/heads/master@{#73800}
1 parent ced669d commit 501482c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/objects/value-serializer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,8 @@ Maybe<T> ValueDeserializer::ReadZigZag() {
12021202

12031203
Maybe<double> ValueDeserializer::ReadDouble() {
12041204
// Warning: this uses host endianness.
1205-
if (position_ > end_ - sizeof(double)) return Nothing<double>();
1205+
if (sizeof(double) > static_cast<unsigned>(end_ - position_))
1206+
return Nothing<double>();
12061207
double value;
12071208
base::Memcpy(&value, position_, sizeof(double));
12081209
position_ += sizeof(double);

0 commit comments

Comments
 (0)