Skip to content
Snippets Groups Projects
Commit 6b3ff98d authored by Simon Glass's avatar Simon Glass
Browse files

Tidy up error checking and fix bug in hash command


There are two problems:

1. The argument count needs to be checked before argv is used
2. When verify is not enabled, we need to define a constant zero value

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent 8ec21bbe
No related branches found
No related tags found
No related merge requests found
...@@ -32,11 +32,15 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ...@@ -32,11 +32,15 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_HASH_VERIFY #ifdef CONFIG_HASH_VERIFY
int verify = 0; int verify = 0;
if (argc < 4)
return CMD_RET_USAGE;
if (!strcmp(argv[1], "-v")) { if (!strcmp(argv[1], "-v")) {
verify = 1; verify = 1;
argc--; argc--;
argv++; argv++;
} }
#else
const int verify = 0;
#endif #endif
/* Move forward to 'algorithm' parameter */ /* Move forward to 'algorithm' parameter */
argc--; argc--;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment