aboutsummaryrefslogtreecommitdiff
path: root/patch_reader.h
diff options
context:
space:
mode:
authorCalder Kitagawa <ckitagawa@google.com>2018-04-27 22:37:45 +0000
committerEdward Lesmes <ehmaldonado@google.com>2021-07-23 22:15:13 +0000
commit673bf5912068218539f524b6dfe74dfb38fe67b8 (patch)
tree736131332e82478023a5f3ef8df6f093e3c78591 /patch_reader.h
parente4ba641db27acdddf3c00dbb1d93615b72487582 (diff)
downloadzucchini-673bf5912068218539f524b6dfe74dfb38fe67b8.tar.gz
[Zucchini] Validate equivalences on load
A follow-up to https://chromium-review.googlesource.com/c/chromium/src/+/1028575 This moves patch_apply logic to check bounds of an equivalences from the call site of GetNext() to an internal function in the patch_reader. This means the equivalence consumer can use the equivalences without checking anything to do with bounds. I have manually tested that this doesn't appear to break any existing valid patches and it appears to catch all the same errors change 1028575 fixed so I can safely reverse that change. BUG: 837096 Change-Id: I84ccd9e1493f32d16eace4dd8e67586f559220d3 Reviewed-on: https://chromium-review.googlesource.com/1028836 Commit-Queue: Calder Kitagawa <ckitagawa@google.com> Reviewed-by: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#554536} NOKEYCHECK=True GitOrigin-RevId: ce5642400b37f5ff2b0a1213522f984bca8a080a
Diffstat (limited to 'patch_reader.h')
-rw-r--r--patch_reader.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/patch_reader.h b/patch_reader.h
index ad517f5..5d3c6dd 100644
--- a/patch_reader.h
+++ b/patch_reader.h
@@ -218,7 +218,11 @@ class PatchElementReader {
const Element& old_element() const { return element_match_.old_element; }
const Element& new_element() const { return element_match_.new_element; }
- // The Get*() functions below return copies of cached sources.
+ // The Get*() functions below return copies of cached sources. Callers may
+ // assume the following:
+ // - Equivalences satisfy basic boundary constraints
+ // - "Old" / "new" blocks lie entirely in "old" / "new" images.
+ // - "New" blocks are sorted.
EquivalenceSource GetEquivalenceSource() const { return equivalences_; }
ExtraDataSource GetExtraDataSource() const { return extra_data_; }
RawDeltaSource GetRawDeltaSource() const { return raw_delta_; }
@@ -231,6 +235,11 @@ class PatchElementReader {
}
private:
+ // Checks that "old" and "new" blocks of each item in |equivalences_| satisfy
+ // basic order and image bound constraints (using |element_match_| data).
+ // Returns true if successful.
+ bool ValidateEquivalences();
+
ElementMatch element_match_;
// Cached sources.