Skip to content

Commit 3ed37c2

Browse files
clarkduvallChromium LUCI CQ
authored andcommitted
Make sure hash prefix checking does not crash with empty prefixes
This moves the start == end check out of the if condition, which should ensure we don't have issues if end == 0. Bug: 327337359 Change-Id: Ic72131102d78ceb0d588ee72edc752a502f1268e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5335041 Commit-Queue: Xinghui Lu <[email protected]> Auto-Submit: Clark DuVall <[email protected]> Commit-Queue: Clark DuVall <[email protected]> Reviewed-by: Xinghui Lu <[email protected]> Cr-Commit-Position: refs/heads/main@{#1267141}
1 parent 1bd3b1d commit 3ed37c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/safe_browsing/core/browser/db/hash_prefix_map.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,11 @@ HashPrefixStr MmapHashPrefixMap::FileInfo::Matches(
618618
start = offsets_[index];
619619
if (++index < offsets_.size())
620620
end = offsets_[index];
621+
}
621622

622-
// If the start is the same as end, the hash doesn't exist.
623-
if (start == end)
624-
return HashPrefixStr();
623+
// If the start is the same as end, the hash doesn't exist.
624+
if (start == end) {
625+
return HashPrefixStr();
625626
}
626627

627628
// TODO(crbug.com/1409674): Remove crash logging.

0 commit comments

Comments
 (0)