Index: gin/isolate_holder.cc |
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc |
index 2b6d64b35c042b2e183e6cc0c963c2f2ab96d392..b4f65f6f0f67234617d2ba47de71a27dfb2e3c2d 100644 |
--- a/gin/isolate_holder.cc |
+++ b/gin/isolate_holder.cc |
@@ -12,6 +12,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/rand_util.h" |
#include "base/sys_info.h" |
+#include "crypto/sha2.h" |
#include "gin/array_buffer.h" |
#include "gin/debug_impl.h" |
#include "gin/function_template.h" |
@@ -72,6 +73,16 @@ bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path, |
return true; |
} |
+bool VerifyV8SnapshotFile(base::MemoryMappedFile* snapshot_file, |
jochen (gone - plz use gerrit)
2015/01/08 15:11:53
#if defined(OS_WIN)
rmcilroy
2015/01/08 16:29:21
Done.
|
+ const unsigned char* fingerprint) { |
+ unsigned char output[crypto::kSHA256Length]; |
+ crypto::SHA256HashString( |
+ base::StringPiece(reinterpret_cast<const char*>(snapshot_file->data()), |
+ snapshot_file->length()), |
+ output, sizeof(output)); |
+ return !memcmp(fingerprint, output, sizeof(output)); |
+} |
+ |
#if !defined(OS_MACOSX) |
const int v8_snapshot_dir = |
#if defined(OS_ANDROID) |
@@ -87,6 +98,11 @@ const int v8_snapshot_dir = |
#ifdef V8_USE_EXTERNAL_STARTUP_DATA |
+ |
+// Declared in gen/gin/v8_snapshot_fingerprint.cc |
+extern const unsigned char g_natives_fingerprint[]; |
+extern const unsigned char g_snapshot_fingerprint[]; |
+ |
// static |
bool IsolateHolder::LoadV8Snapshot() { |
if (g_mapped_natives && g_mapped_snapshot) |
@@ -118,6 +134,15 @@ bool IsolateHolder::LoadV8SnapshotFD(int natives_fd, int snapshot_fd) { |
return MapV8Files(NULL, NULL, natives_fd, snapshot_fd); |
} |
+ |
+// static |
+bool IsolateHolder::LoadAndVerifyV8Snapshot() { |
jochen (gone - plz use gerrit)
2015/01/08 15:11:53
#if OS_WIN
rmcilroy
2015/01/08 16:29:21
Done (and also ifdeffed out LoadV8Snapshot on Wind
|
+ if (!LoadV8Snapshot()) |
+ return false; |
+ return VerifyV8SnapshotFile(g_mapped_natives, g_natives_fingerprint) && |
+ VerifyV8SnapshotFile(g_mapped_snapshot, g_snapshot_fingerprint); |
+} |
+ |
#endif // V8_USE_EXTERNAL_STARTUP_DATA |
//static |