aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/api.go
diff options
context:
space:
mode:
authorGuillaume Ballet <gballet@gmail.com>2018-03-27 23:26:08 +0800
committerGitHub <noreply@github.com>2018-03-27 23:26:08 +0800
commit80449719bd664bb0ed9c599765f6313f9b8a8303 (patch)
tree3294e5add82a09386532d97f156dc390431348a5 /whisper/whisperv6/api.go
parent45bd4feddeadfbde5d1e560797155aacb0abbadf (diff)
downloaddexon-80449719bd664bb0ed9c599765f6313f9b8a8303.tar
dexon-80449719bd664bb0ed9c599765f6313f9b8a8303.tar.gz
dexon-80449719bd664bb0ed9c599765f6313f9b8a8303.tar.bz2
dexon-80449719bd664bb0ed9c599765f6313f9b8a8303.tar.lz
dexon-80449719bd664bb0ed9c599765f6313f9b8a8303.tar.xz
dexon-80449719bd664bb0ed9c599765f6313f9b8a8303.tar.zst
dexon-80449719bd664bb0ed9c599765f6313f9b8a8303.zip
whisper: fix issue in topic list copy (#16381)
- Fixes #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.
Diffstat (limited to 'whisper/whisperv6/api.go')
-rw-r--r--whisper/whisperv6/api.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/whisper/whisperv6/api.go b/whisper/whisperv6/api.go
index 96e2b17e7..3f3a082af 100644
--- a/whisper/whisperv6/api.go
+++ b/whisper/whisperv6/api.go
@@ -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[:])
}
}