From cd145f4fcbbc7971f88db4805ea02c801df90545 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 5 Sep 2024 14:21:54 -0300 Subject: [PATCH] nip19: fix decoding faulty kind from tlv. --- nip19/nip19.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nip19/nip19.go b/nip19/nip19.go index c9b4466..6cc7027 100644 --- a/nip19/nip19.go +++ b/nip19/nip19.go @@ -84,7 +84,11 @@ func Decode(bech32string string) (prefix string, value any, err error) { } result.Author = hex.EncodeToString(v) case TLVKind: - result.Kind = int(binary.BigEndian.Uint32(v)) + if len(v) == 4 { + result.Kind = int(binary.BigEndian.Uint32(v)) + } else { + return prefix, nil, fmt.Errorf("invalid uint32 value for integer (%v)", v) + } default: // ignore }