From 54c4b09f87d6069735eb62d436fc596ee2966d81 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 30 Jul 2018 18:30:19 -0700 Subject: [PATCH] discovery/gossiper: copy bolt key to prevent panic Corrects an instance that holds a reference to a boltdb byte slice after returning from the transaction. This can cause panics under certain conditions, which is avoided by creating a copy of the key. --- discovery/gossiper.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index a7b70ba5..dd94f58a 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -796,7 +796,13 @@ func (d *AuthenticatedGossiper) resendAnnounceSignatures() error { if err != nil { return err } - t := msgTuple{peer, msg, k} + + // Make a copy of the database key corresponding to + // these AnnounceSignatures. + dbKey := make([]byte, len(k)) + copy(dbKey, k) + + t := msgTuple{peer, msg, dbKey} // Add the message to the slice, such that we can // resend it after the database transaction is over.