aboutsummaryrefslogtreecommitdiff
path: root/target_pool.h
diff options
context:
space:
mode:
authorCalder Kitagawa <ckitagawa@chromium.org>2018-05-24 21:38:49 +0000
committerEdward Lesmes <ehmaldonado@google.com>2021-07-23 22:40:26 +0000
commit984b1815afc913c3021ce6a83a1fafd9da61c802 (patch)
tree8026361ba26b794683afb31575a7ee723f584e67 /target_pool.h
parentc4290b536703a052b79fa321fcdecd73bc99d484 (diff)
downloadzucchini-984b1815afc913c3021ce6a83a1fafd9da61c802.tar.gz
[Zucchini]: Fix bugs found by Apply fuzzer
Located by fuzzing ZTF Apply (WIP): https://chromium-review.googlesource.com/c/chromium/src/+/1072231 Found two fatal errors: - OffsetForKey always assumes a key is valid however, the validity of the key is not checked prior to the caller invoking the method. The caller also had no way to check validity if it was external to TargetPool. Fix: Add a method to check for key validity ahead of calling OffsetForKey. - ConvertToTargetLineCol for absolute references had a logic bug that resulted in attempting to dereference an invalid base::Optional Fix: Change the logic to avoid issue. Bug: 835341 Change-Id: I99c91741eef41dfaa3036af8e708eb3f0d5ca84a Reviewed-on: https://chromium-review.googlesource.com/1072272 Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#561642} NOKEYCHECK=True GitOrigin-RevId: 4e3e49f97119d48ba6c048e46aa9671d1cd21d17
Diffstat (limited to 'target_pool.h')
-rw-r--r--target_pool.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/target_pool.h b/target_pool.h
index b881b1e..27884d6 100644
--- a/target_pool.h
+++ b/target_pool.h
@@ -54,6 +54,9 @@ class TargetPool {
// this class.
offset_t OffsetForKey(key_t key) const { return targets_[key]; }
+ // Returns whether a particular key is valid.
+ bool KeyIsValid(key_t key) const { return key < targets_.size(); }
+
// Uses |offset_mapper| to transform "old" |targets_| to "new" |targets_|,
// resulting in sorted and unique targets.
void FilterAndProject(const OffsetMapper& offset_mapper);