Skip to content

Commit

Permalink
whisper: fix issue in topic list copy (ethereum#16381)
Browse files Browse the repository at this point in the history
- Fixes ethereum#16271. What was appeneded was a pointer to
an object that changes during the iteration.
- The topic is allocated as a 4-byte array, fill partial topics
with 0s. Partial topics are currently disabled, but would
crash as they rely on the presence of byte number 3.
  • Loading branch information
gballet authored and mariameda committed Aug 19, 2018
1 parent 61bfb5d commit 30ac0eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions whisper/whisperv6/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,10 @@ func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error) {
}

if len(req.Topics) > 0 {
topics = make([][]byte, 0, len(req.Topics))
for _, topic := range req.Topics {
topics = append(topics, topic[:])
topics = make([][]byte, len(req.Topics))
for i, topic := range req.Topics {
topics[i] = make([]byte, TopicLength)
copy(topics[i], topic[:])
}
}

Expand Down
2 changes: 1 addition & 1 deletion whisper/whisperv6/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

"github.com/NiluPlatform/go-nilu/common"
"github.com/ethereum/go-ethereum/common"
set "gopkg.in/fatih/set.v0"
)

Expand Down

0 comments on commit 30ac0eb

Please sign in to comment.