diff --git a/whisper/whisperv5/filter.go b/whisper/whisperv5/filter.go index b5e893e0ff..6568c0aea4 100644 --- a/whisper/whisperv5/filter.go +++ b/whisper/whisperv5/filter.go @@ -220,6 +220,10 @@ func matchSingleTopic(topic TopicType, bt []byte) bool { bt = bt[:4] } + if len(bt) < 4 { + return false + } + for j, b := range bt { if topic[j] != b { return false diff --git a/whisper/whisperv6/filter.go b/whisper/whisperv6/filter.go index 2f52dd6b98..d1e2c447f8 100644 --- a/whisper/whisperv6/filter.go +++ b/whisper/whisperv6/filter.go @@ -225,6 +225,10 @@ func matchSingleTopic(topic TopicType, bt []byte) bool { bt = bt[:4] } + if len(bt) < 4 { + return false + } + for j, b := range bt { if topic[j] != b { return false