diff options
| author | Simon Glass <sjg@chromium.org> | 2013-02-24 17:33:11 +0000 | 
|---|---|---|
| committer | Simon Glass <sjg@chromium.org> | 2013-02-28 19:09:21 -0800 | 
| commit | 6b3ff98da41a084658877282057adeb59ff6e9f2 (patch) | |
| tree | 6bf3d26a57cb2176824143f71fd9397e2f68c951 /common/cmd_hash.c | |
| parent | 8ec21bbe5c45fc80ca74eb403ab5b00a9e1f699f (diff) | |
| download | olio-uboot-2014.01-6b3ff98da41a084658877282057adeb59ff6e9f2.tar.xz olio-uboot-2014.01-6b3ff98da41a084658877282057adeb59ff6e9f2.zip | |
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: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/cmd_hash.c')
| -rw-r--r-- | common/cmd_hash.c | 4 | 
1 files changed, 4 insertions, 0 deletions
| diff --git a/common/cmd_hash.c b/common/cmd_hash.c index 689c60857..eb6a33873 100644 --- a/common/cmd_hash.c +++ b/common/cmd_hash.c @@ -32,11 +32,15 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])  #ifdef CONFIG_HASH_VERIFY  	int verify = 0; +	if (argc < 4) +		return CMD_RET_USAGE;  	if (!strcmp(argv[1], "-v")) {  		verify = 1;  		argc--;  		argv++;  	} +#else +	const int verify = 0;  #endif  	/* Move forward to 'algorithm' parameter */  	argc--; |