mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
tools/hsmtool: correct bad access to argv[]
This commit is contained in:
committed by
Christian Decker
parent
e5e4958909
commit
36e8d83a62
@@ -365,25 +365,25 @@ int main(int argc, char *argv[])
|
|||||||
setup_locale();
|
setup_locale();
|
||||||
err_set_progname(argv[0]);
|
err_set_progname(argv[0]);
|
||||||
|
|
||||||
method = argv[1];
|
method = argc > 1 ? argv[1] : NULL;
|
||||||
if (!method)
|
if (!method)
|
||||||
show_usage();
|
show_usage();
|
||||||
|
|
||||||
if (streq(method, "decrypt")) {
|
if (streq(method, "decrypt")) {
|
||||||
if (!argv[2] || !argv[3])
|
if (argc < 3)
|
||||||
show_usage();
|
show_usage();
|
||||||
return decrypt_hsm(argv[2], argv[3]);
|
return decrypt_hsm(argv[2], argv[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streq(method, "encrypt")) {
|
if (streq(method, "encrypt")) {
|
||||||
if (!argv[2] || !argv[3])
|
if (argc < 3)
|
||||||
show_usage();
|
show_usage();
|
||||||
return encrypt_hsm(argv[2], argv[3]);
|
return encrypt_hsm(argv[2], argv[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streq(method, "dumpcommitments")) {
|
if (streq(method, "dumpcommitments")) {
|
||||||
/* node_id channel_id depth hsm_secret ?password? */
|
/* node_id channel_id depth hsm_secret ?password? */
|
||||||
if (!(argv[2] && argv[3] && argv[4] && argv[5]))
|
if (argc < 5)
|
||||||
show_usage();
|
show_usage();
|
||||||
struct node_id node_id;
|
struct node_id node_id;
|
||||||
if (!node_id_from_hexstr(argv[2], strlen(argv[2]), &node_id))
|
if (!node_id_from_hexstr(argv[2], strlen(argv[2]), &node_id))
|
||||||
|
|||||||
Reference in New Issue
Block a user