common: Fix off-by-one in from_bech32_charset

`bech32_charset_rev` is only 128 bytes in size but the `c < 0 || c > 128` check allows for `c` to be equal to 128 which would be out-of-bounds. Fix this off-by-one bug by changing the check to `c >= 128`.
This commit is contained in:
Niklas Gögge 2024-05-17 16:37:36 +01:00 committed by Vincenzo Palazzo
parent 7040d49242
commit 123166790f

View File

@ -82,9 +82,9 @@ bool from_bech32_charset(const tal_t *ctx,
u5data = tal_arr(NULL, u5, datalen);
for (size_t i = 0; i < datalen; i++) {
int c = sep[1+i];
if (c < 0 || c > 128)
goto fail;
c = fixup_char(c, &upper, &lower);
if (c < 0 || c >= 128)
goto fail;
if (bech32_charset_rev[c] == -1)
goto fail;
u5data[i] = bech32_charset_rev[c];