Skip to content

Commit

Permalink
Do not leak records (paritytech#13086)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored Jan 6, 2023
1 parent bc73ebf commit 363ce0a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ impl NetworkBehaviour for DiscoveryBehaviour {
}
}

// Will be removed below when we receive
// `FinishedWithNoAdditionalRecord`.
self.records_to_publish.insert(id, r.record.clone());

DiscoveryOut::ValueFound(
Expand All @@ -726,13 +728,14 @@ impl NetworkBehaviour for DiscoveryBehaviour {
Ok(GetRecordOk::FinishedWithNoAdditionalRecord {
cache_candidates,
}) => {
if cache_candidates.is_empty() {
continue
}

// Put the record to the `cache_candidates` that are nearest to the
// record key from our point of view of the network.
// We always need to remove the record to not leak any data!
if let Some(record) = self.records_to_publish.remove(&id) {
if cache_candidates.is_empty() {
continue
}

// Put the record to the `cache_candidates` that are nearest to
// the record key from our point of view of the network.
if let Some(kad) = self.kademlia.as_mut() {
kad.put_record_to(
record,
Expand Down

0 comments on commit 363ce0a

Please sign in to comment.