Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: src/snapshot/code-serializer.cc

Issue 2736923002: SnapshotCreator: start from existing snapshot if we have one (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/snapshot/code-serializer.cc
diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc
index 7f57f0aa645bab4419a173ad13477789d894010f..5f0e424957b4347ebc04e57aec4b8c7c5565419d 100644
--- a/src/snapshot/code-serializer.cc
+++ b/src/snapshot/code-serializer.cc
@@ -411,10 +411,14 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
if (this->size_ < kHeaderSize) return INVALID_HEADER;
uint32_t magic_number = GetMagicNumber();
if (magic_number != ComputeMagicNumber(isolate)) return MAGIC_NUMBER_MISMATCH;
+ if (GetExtraReferences() > GetExtraReferences(isolate)) {
+ return MAGIC_NUMBER_MISMATCH;
+ }
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset);
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
+ uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
uint32_t c1 = GetHeaderValue(kChecksum1Offset);
uint32_t c2 = GetHeaderValue(kChecksum2Offset);
if (version_hash != Version::Hash()) return VERSION_MISMATCH;
@@ -423,6 +427,12 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
return CPU_FEATURES_MISMATCH;
}
if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
+ uint32_t max_payload_length =
+ this->size_ -
+ POINTER_SIZE_ALIGN(kHeaderSize +
Yang 2017/03/07 11:28:11 See above. Let's not align.
Jakob Kummerow 2017/03/07 12:39:15 See above -- if we align one, we need to align the
+ GetHeaderValue(kNumReservationsOffset) * kInt32Size +
+ GetHeaderValue(kNumCodeStubKeysOffset) * kInt32Size);
+ if (payload_length > max_payload_length) return LENGTH_MISMATCH;
if (!Checksum(DataWithoutHeader()).Check(c1, c2)) return CHECKSUM_MISMATCH;
return CHECK_SUCCESS;
}

Powered by Google App Engine
This is Rietveld 408576698