mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-22 06:41:06 +02:00
nip19: guard against broken TLVs.
fixes https://github.com/nbd-wtf/go-nostr/issues/161
This commit is contained in:
parent
2dba8fc3e0
commit
d0476edd06
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user