mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
Avoid segfault on CLI command "decodepay 1111111" (invalid short bech32 string)
Before this patch: ``` $ cli/lightning-cli decodepay 1111111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 111111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 11111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 1111111 lightning-cli: Non-object response '' $ cli/lightning-cli decodepay 1111111 lightning-cli: Connecting to 'lightning-rpc': Connection refused ``` After this patch: ``` $ cli/lightning-cli decodepay 1111111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 111111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 11111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 1111111 "Invalid bolt11: Bad bech32 string" $ cli/lightning-cli decodepay 1111111 "Invalid bolt11: Bad bech32 string" ```
This commit is contained in:
parent
5319ff1bc0
commit
a87c8a74b5
@ -474,6 +474,9 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
|
|||||||
|
|
||||||
b11->routes = tal_arr(b11, struct route_info *, 0);
|
b11->routes = tal_arr(b11, struct route_info *, 0);
|
||||||
|
|
||||||
|
if (strlen(str) < 8)
|
||||||
|
return decode_fail(b11, fail, "Bad bech32 string");
|
||||||
|
|
||||||
hrp = tal_arr(tmpctx, char, strlen(str) - 6);
|
hrp = tal_arr(tmpctx, char, strlen(str) - 6);
|
||||||
data = tal_arr(tmpctx, u5, strlen(str) - 8);
|
data = tal_arr(tmpctx, u5, strlen(str) - 8);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user