Skip to content

Commit

Permalink
tools/hsmtool: correct bad access to argv[]
Browse files Browse the repository at this point in the history
  • Loading branch information
darosior authored and cdecker committed Nov 29, 2019
1 parent e5e4958 commit 36e8d83
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/hsmtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,25 +365,25 @@ int main(int argc, char *argv[])
setup_locale();
err_set_progname(argv[0]);

method = argv[1];
method = argc > 1 ? argv[1] : NULL;
if (!method)
show_usage();

if (streq(method, "decrypt")) {
if (!argv[2] || !argv[3])
if (argc < 3)
show_usage();
return decrypt_hsm(argv[2], argv[3]);
}

if (streq(method, "encrypt")) {
if (!argv[2] || !argv[3])
if (argc < 3)
show_usage();
return encrypt_hsm(argv[2], argv[3]);
}

if (streq(method, "dumpcommitments")) {
/* node_id channel_id depth hsm_secret ?password? */
if (!(argv[2] && argv[3] && argv[4] && argv[5]))
if (argc < 5)
show_usage();
struct node_id node_id;
if (!node_id_from_hexstr(argv[2], strlen(argv[2]), &node_id))
Expand Down

0 comments on commit 36e8d83

Please sign in to comment.