node/pkg/p2p: Prevent potential nil pointer dereference when processing heartbeats
Resolves the problem occurring when dereferencing a nil `gk *ecdsa.PublicKey` during heartbeat processing. This issue arises when non-guardian processes utilizing the p2p package set the key to `nil`.
This commit is contained in:
parent
745351199b
commit
dfbdc9afb4
|
@ -607,7 +607,7 @@ func Run(
|
||||||
zap.String("from", envelope.GetFrom().String()))
|
zap.String("from", envelope.GetFrom().String()))
|
||||||
} else {
|
} else {
|
||||||
guardianAddr := eth_common.BytesToAddress(s.GuardianAddr)
|
guardianAddr := eth_common.BytesToAddress(s.GuardianAddr)
|
||||||
if guardianAddr != ethcrypto.PubkeyToAddress(gk.PublicKey) {
|
if gk == nil || guardianAddr != ethcrypto.PubkeyToAddress(gk.PublicKey) {
|
||||||
prevPeerId, ok := components.ProtectedHostByGuardianKey[guardianAddr]
|
prevPeerId, ok := components.ProtectedHostByGuardianKey[guardianAddr]
|
||||||
if ok {
|
if ok {
|
||||||
if prevPeerId != peerId {
|
if prevPeerId != peerId {
|
||||||
|
|
Loading…
Reference in New Issue