Page MenuHomePhabricator

Fix out-of-bounds index in Avalanche PeerManager
AbandonedPublic

Authored by jasonbcox on Jun 30 2020, 03:35.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Summary
Test Plan

build-configurations.py build-asan

Event Timeline

Fabien added inline comments.
src/avalanche/peermanager.cpp
82

slots.size() could be end here, and you could simply return NO_PEER instead of a break. In the end the result is the same: after the break you will exit the while loop, jump over the for loop (because end - begin is necessarily <= 0) and return NO_PEER anyway.

deadalnix requested changes to this revision.Jun 30 2020, 13:29
deadalnix added a subscriber: deadalnix.
deadalnix added inline comments.
src/avalanche/peermanager.cpp
72

Adding an assert that i is in the right range is a good idea here.

82

Indeed, this has nothing to do with size and everything to do with the need to early bail.

This revision now requires changes to proceed.Jun 30 2020, 13:29