diff options
Diffstat (limited to 'patch_reader.cc')
-rw-r--r-- | patch_reader.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/patch_reader.cc b/patch_reader.cc index 99951da..8fd9b57 100644 --- a/patch_reader.cc +++ b/patch_reader.cc @@ -10,6 +10,7 @@ #include "base/numerics/safe_conversions.h" #include "components/zucchini/algorithm.h" #include "components/zucchini/crc32.h" +#include "components/zucchini/element_detection.h" namespace zucchini { @@ -27,6 +28,12 @@ bool ParseElementMatch(BufferSource* source, ElementMatch* element_match) { LOG(ERROR) << "Invalid ExecutableType found."; return false; } + uint16_t element_version = DisassemblerVersionOfType(exe_type); + if (element_version != unsafe_element_header.version) { + LOG(ERROR) << "Element version doesn't match. Expected: " << element_version + << ", Actual:" << unsafe_element_header.version; + return false; + } if (!unsafe_element_header.old_length || !unsafe_element_header.new_length) { LOG(ERROR) << "Empty patch element found."; return false; @@ -334,6 +341,11 @@ bool EnsemblePatchReader::Initialize(BufferSource* source) { LOG(ERROR) << "Patch contains invalid magic."; return false; } + if (header_.major_version != kMajorVersion) { + LOG(ERROR) << "Patch major version doesn't match. Expected: " + << kMajorVersion << ", Actual:" << header_.major_version; + return false; + } // |header_| is assumed to be safe from this point forward. uint32_t element_count = 0; |