From 05eb11e302bf71bcfc4113c563abc7cb0df35f11 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 29 Sep 2024 16:47:29 -0300 Subject: [PATCH] handle invalid subscription id from relay on subIdToSerial(). --- helpers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers.go b/helpers.go index aac13a3..de13bf1 100644 --- a/helpers.go +++ b/helpers.go @@ -96,6 +96,10 @@ func arePointerValuesEqual[V comparable](a *V, b *V) bool { } func subIdToSerial(subId string) int64 { - serialId, _ := strconv.ParseInt(subId[0:strings.Index(subId, ":")], 10, 64) + n := strings.Index(subId, ":") + if n < 0 || n > len(subId) { + return -1 + } + serialId, _ := strconv.ParseInt(subId[0:n], 10, 64) return serialId }