betterbinary: prevent binary index overflow by casting the numbers to int (from uint16).

This commit is contained in:
fiatjaf
2025-08-25 18:01:34 -03:00
parent a581d9677d
commit d345bb3529

View File

@@ -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
}