Skip to content

Commit

Permalink
Merge pull request from GHSA-pr39-8257-fxc2
Browse files Browse the repository at this point in the history
fix: fix multiaddr convert to socket unwrap
  • Loading branch information
doitian authored Jun 16, 2020
2 parents c4ccdc8 + ecaedd3 commit d909cde
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions network/src/protocols/discovery/substream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ impl SubstreamValue {
count: MAX_ADDR_TO_SEND as u32,
listen_port: substream.listen_port,
});
addr_known.insert(RawAddr::from(
multiaddr_to_socketaddr(&substream.remote_addr).unwrap(),
));
if let Some(addr) = multiaddr_to_socketaddr(&substream.remote_addr) {
addr_known.insert(RawAddr::from(addr));
}

RemoteAddress::Listen(substream.remote_addr)
} else {
Expand Down Expand Up @@ -389,7 +389,11 @@ impl Substream {
context
.listens()
.iter()
.map(|address| multiaddr_to_socketaddr(address).unwrap().port())
.map(|address| {
multiaddr_to_socketaddr(address)
.map(|addr| addr.port())
.unwrap_or_default()
})
.next()
} else {
None
Expand Down

0 comments on commit d909cde

Please # to comment.