Skip to content

Commit

Permalink
upstream: fix PriorityStateManager indexing (#3856)
Browse files Browse the repository at this point in the history
The PriorityStateManager is indexing off the end of an array when the priority is large enough:

Risk Level: Low
Testing: Verified that the out-of-bounds indexing is actually happening by testing with an additional assert.
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Alex Konradi <akonradi@google.com>
  • Loading branch information
akonradi authored and alyssawilk committed Jul 16, 2018
1 parent 45fe83e commit cf12ea5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/common/upstream/upstream_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,8 @@ void PriorityStateManager::updateClusterPrioritySet(
HostVectorSharedPtr hosts(std::move(current_hosts));
LocalityWeightsMap empty_locality_map;
LocalityWeightsMap& locality_weights_map =
priority_state_.empty() ? empty_locality_map : priority_state_[priority].second;
priority_state_.size() > priority ? priority_state_[priority].second : empty_locality_map;
ASSERT(priority_state_.size() > priority || locality_weights_map.empty());
LocalityWeightsSharedPtr locality_weights;
std::vector<HostVector> per_locality;

Expand Down

0 comments on commit cf12ea5

Please sign in to comment.