From 40f686b21df809e30bdc46ac817adcc18fc9b4dd Mon Sep 17 00:00:00 2001 From: b00ris Date: Fri, 5 Jan 2018 00:16:35 +0300 Subject: [PATCH] whisper: add check to matchSingleTopic --- whisper/whisperv5/filter.go | 4 ++++ whisper/whisperv6/filter.go | 4 ++++ 2 files changed, 8 insertions(+) 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