mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
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:
parent
7040d49242
commit
123166790f
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user