aboutsummaryrefslogtreecommitdiff
path: root/patch_reader.h
diff options
context:
space:
mode:
authorCalder Kitagawa <ckitagawa@google.com>2018-05-02 15:27:28 +0000
committerEdward Lesmes <ehmaldonado@google.com>2021-07-23 22:18:32 +0000
commit02a83192e9f50cd6ecdf750e1c13a0f233b5aea7 (patch)
tree9dc3383e0a527725b790bf0c86c5df0a5e5803ee /patch_reader.h
parent6951a286379338eaa10a712989541ca77c0c2a9c (diff)
downloadzucchini-02a83192e9f50cd6ecdf750e1c13a0f233b5aea7.tar.gz
[Zucchini]: Stricter patch read
This enforces a stricter patch read in a few ways: - Raw Deltas of 0 are forbidden. These are unused values which have no meaning and should not appear. - Extra Data length must be equal to the size of the patch element minus the total length of equivalences. - Element match headers must have regions of nonzero length. This change also annotates a number of "unsafe" values read from the patch that could be sources of error later if unchecked. It also adds caveats about under what conditions emitted values are considered to be safe/unsafe. Bug: 837096 Change-Id: I1b7614d92b85c0a1546d8dccb7d371d28b2a4cd3 Reviewed-on: https://chromium-review.googlesource.com/1037186 Commit-Queue: Calder Kitagawa <ckitagawa@google.com> Reviewed-by: Samuel Huang <huangs@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/master@{#555396} NOKEYCHECK=True GitOrigin-RevId: 63f65c0a8b295b925c1dc92c7bed7625e7d99d46
Diffstat (limited to 'patch_reader.h')
-rw-r--r--patch_reader.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/patch_reader.h b/patch_reader.h
index 5d3c6dd..515da50 100644
--- a/patch_reader.h
+++ b/patch_reader.h
@@ -168,13 +168,13 @@ class ReferenceDeltaSource {
// Core functions.
bool Initialize(BufferSource* source);
base::Optional<int32_t> GetNext();
- bool Done() const { return reference_delta_.empty(); }
+ bool Done() const { return source_.empty(); }
// Accessors for unittest.
- BufferSource reference_delta() const { return reference_delta_; }
+ BufferSource reference_delta() const { return source_; }
private:
- BufferSource reference_delta_;
+ BufferSource source_;
};
// Source for additional targets.
@@ -236,9 +236,10 @@ 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();
+ // basic order and image bound constraints (using |element_match_| data). Also
+ // validates that the amount of extra data is correct. Returns true if
+ // successful.
+ bool ValidateEquivalencesAndExtraData();
ElementMatch element_match_;