fix memory safety: use-after-free in DHT, buffer overflows in TURN,
integer truncation
This commit is contained in:
@@ -336,6 +336,15 @@ pub fn disconnectPeerImpl(p2p: *P2P, peer_id: PeerId) Error!void {
|
||||
p2p.allocator.destroy(socket);
|
||||
}
|
||||
|
||||
// Clear DHT node-to-peer mapping to prevent stale identity spoofing on reconnect
|
||||
{
|
||||
p2p.dht_node_to_peer_mutex.lock();
|
||||
defer p2p.dht_node_to_peer_mutex.unlock();
|
||||
if (p2p.peer_to_dht_node.fetchRemove(peer_id)) |kv| {
|
||||
_ = p2p.dht_node_to_peer.remove(kv.value);
|
||||
}
|
||||
}
|
||||
|
||||
// LEAK FIX: Also remove from peer_manager to free the address string
|
||||
// Previously only removed from peer_connections, leaking the peer entry
|
||||
if (p2p.peer_manager) |pm| {
|
||||
|
||||
Reference in New Issue
Block a user