Make persistent cache serialization safer
Add a version tag at the start, reject any cache blobs without it
Bug: chromium:1062018
Change-Id: I18bb668e6b836e1247640e9286a69a3e745babfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277376
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/gpu/MemoryCache.cpp b/tools/gpu/MemoryCache.cpp
index 4da7fd7..d8fdaf7 100644
--- a/tools/gpu/MemoryCache.cpp
+++ b/tools/gpu/MemoryCache.cpp
@@ -97,7 +97,7 @@
// run glslang on the input.
const char* ext = GrBackendApi::kOpenGL == api ? "frag" : "spv";
SkReader32 reader(data->data(), data->size());
- reader.readU32(); // Shader type tag
+ GrPersistentCacheUtils::GetType(&reader); // Shader type tag
GrPersistentCacheUtils::UnpackCachedShaders(&reader, shaders,
inputsIgnored, kGrShaderTypeCount);