-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
pub fn has_all_pages(&mut self) -> bool {
self.pages.sort_by(|a, b| a.page.cmp(&b.page));
for i in 0..(self.last_page + 1) {
if self.pages[i as usize].page != i {
return false;
}
}
true
}
This indexes self.pages[i] without checking length.
If
- receive page 1 before page 0, or
- miss any page, or
- receive duplicates and still don’t have a full contiguous set,
then
- self.pages.len() can be < last_page+1 and this will panic.
In handle_universe_discovery_packet(), if the first packet seen from a source is page > 0, it still creates a partially discovered source with that single page. Later, has_all_pages() can be called while still missing page 0, and will panic.
Fix: check self.pages.len() >= (self.last_page as usize + 1) before indexing, or rewrite to a set/bitmask presence check.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working