From fae061cec0e17c5604d1e97cf3acb44f39cc5eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Mon, 11 Aug 2025 16:35:26 -0700 Subject: [PATCH] Fix MAX_PREFIX parameter on bolt11 parsing logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: https://github.com/damus-io/damus/issues/3187 Changelog-None Signed-off-by: Daniel D’Aquino --- nostrdb/src/bolt11/bech32.c | 3 ++- nostrdb/src/content_parser.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nostrdb/src/bolt11/bech32.c b/nostrdb/src/bolt11/bech32.c index 5b335b98..9d4f202e 100644 --- a/nostrdb/src/bolt11/bech32.c +++ b/nostrdb/src/bolt11/bech32.c @@ -162,7 +162,8 @@ bech32_encoding bech32_decode(char* hrp, uint8_t *data, size_t *data_len, const if (len > max_input_len) { return BECH32_ENCODING_NONE; } - return bech32_decode_len(hrp, data, data_len, input, len, 8); + static const int MAX_PREFIX = 9; // 8 bytes for the text, 1 byte for the null terminator + return bech32_decode_len(hrp, data, data_len, input, len, MAX_PREFIX); } int bech32_convert_bits(uint8_t* out, size_t* outlen, int outbits, const uint8_t* in, size_t inlen, int inbits, int pad) { diff --git a/nostrdb/src/content_parser.c b/nostrdb/src/content_parser.c index ccbb4085..ca0e358f 100644 --- a/nostrdb/src/content_parser.c +++ b/nostrdb/src/content_parser.c @@ -113,7 +113,7 @@ static int push_bech32_mention(struct ndb_content_parser *p, struct ndb_str_bloc uint16_t *u8_size; enum nostr_bech32_type type; size_t u5_out_len, u8_out_len; - static const int MAX_PREFIX = 9; + static const int MAX_PREFIX = 9; // 8 bytes for the text, 1 byte for the null terminator char prefix[9] = {0}; start = p->buffer.p;