From d345bb3529fc7c66b9d0419999c260809437068b Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 25 Aug 2025 18:01:34 -0300 Subject: [PATCH] betterbinary: prevent binary index overflow by casting the numbers to int (from uint16). --- eventstore/codec/betterbinary/codec.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eventstore/codec/betterbinary/codec.go b/eventstore/codec/betterbinary/codec.go index 37a9b27..5c24841 100644 --- a/eventstore/codec/betterbinary/codec.go +++ b/eventstore/codec/betterbinary/codec.go @@ -122,9 +122,9 @@ func Unmarshal(data []byte, evt *nostr.Event) (err error) { nitems := int(data[tagbase+offset]) tag := make(nostr.Tag, nitems) - curr := tagbase + offset + 1 + curr := int(tagbase + offset + 1) for i := range tag { - length := binary.LittleEndian.Uint16(data[curr:]) + length := int(binary.LittleEndian.Uint16(data[curr:])) tag[i] = string(data[curr+2 : curr+2+length]) curr += 2 + length }