mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-15 00:27:43 +01:00
nip19: guard against broken TLVs.
fixes https://github.com/nbd-wtf/go-nostr/issues/161
This commit is contained in:
@@ -18,6 +18,10 @@ func readTLVEntry(data []byte) (typ uint8, value []byte) {
|
|||||||
|
|
||||||
typ = data[0]
|
typ = data[0]
|
||||||
length := int(data[1])
|
length := int(data[1])
|
||||||
|
if len(data) < 2+length {
|
||||||
|
return typ, nil
|
||||||
|
}
|
||||||
|
|
||||||
value = data[2 : 2+length]
|
value = data[2 : 2+length]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user