From a1898b699d4664ec0326dcd5f7b505ab8fa4983d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 31 Oct 2018 11:43:49 +1030 Subject: [PATCH] bech32: fix overflow bug. Copied from upstream: https://github.com/sipa/bech32/commit/2b0aac650ce560fb2b2a2bebeacaa5c87d7e5938 Signed-off-by: Rusty Russell --- common/bech32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/bech32.c b/common/bech32.c index d689b1fb9..cc62abdc0 100644 --- a/common/bech32.c +++ b/common/bech32.c @@ -99,7 +99,7 @@ int bech32_decode(char* hrp, uint8_t *data, size_t *data_len, const char *input, ++(*data_len); } hrp_len = input_len - (1 + *data_len); - if (hrp_len < 1 || *data_len < 6) { + if (1 + *data_len >= input_len || *data_len < 6) { return 0; } *(data_len) -= 6;