From 3c89e1f7b39e3c16966947f3e8ed66e3a97b8f17 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Mon, 27 Apr 2020 13:50:09 +0300 Subject: [PATCH] [NOD-952] Fix nil derefernce bug on outboundPeerConnectionFailed (#704) --- database/cursor.go | 3 +-- server/p2p/p2p.go | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/database/cursor.go b/database/cursor.go index 91a4bd807..0727f47ca 100644 --- a/database/cursor.go +++ b/database/cursor.go @@ -16,8 +16,7 @@ type Cursor interface { Seek(key *Key) error // Key returns the key of the current key/value pair, or ErrNotFound if done. - // Note that the key is trimmed to not include the prefix the cursor was opened - // with. The caller should not modify the contents of the returned slice, and + // The caller should not modify the contents of the returned key, and // its contents may change on the next call to Next. Key() (*Key, error) diff --git a/server/p2p/p2p.go b/server/p2p/p2p.go index 8d85b34c5..05832eb64 100644 --- a/server/p2p/p2p.go +++ b/server/p2p/p2p.go @@ -1047,6 +1047,12 @@ func (s *Server) outboundPeerConnected(state *peerState, msg *outboundPeerConnec // outboundPeerConnected is invoked by the connection manager when a new // outbound connection failed to be established. func (s *Server) outboundPeerConnectionFailed(msg *outboundPeerConnectionFailedMsg) { + // If the connection request has no address + // associated to it, do nothing. + if msg.connReq.Addr == nil { + return + } + host, portStr, err := net.SplitHostPort(msg.connReq.Addr.String()) if err != nil { srvrLog.Debugf("Cannot extract address host and port %s: %s", msg.connReq.Addr, err)