nip19: guard against broken TLVs.

fixes https://github.com/nbd-wtf/go-nostr/issues/161
This commit is contained in:
fiatjaf 2024-12-18 11:53:10 -03:00
parent 2dba8fc3e0
commit d0476edd06

View File

@ -18,6 +18,10 @@ func readTLVEntry(data []byte) (typ uint8, value []byte) {
typ = data[0]
length := int(data[1])
if len(data) < 2+length {
return typ, nil
}
value = data[2 : 2+length]
return
}