Skip to contentSkip to conversation

hash.c: Correct non-hash subcommand crc32 addr-save support

PATCH In review Tom Rini 1 participant 2 messages Nov 7, 2013 – Nov 25, 2013

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 hash.c: Correct non-hash subcommand crc32 addr-save support

In the case of not having CONFIG_CMD_HASH but having CONFIG_CMD_CRC32 enabled (and not CONFIG_CRC32_VERIFY), we end up in this part of the code path on hash_command(). However, we will only have exactly 3 args here, and 3 > 3 is false, and we will not try and store the hash at the address given as arg #3. The next problem however is that we've been moving argv around so the third value is now in argv[0] not argv[3].

Confirmed on AM335x Beaglebone White.

---
 common/hash.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/hash.c +2 -2
index 722c40b..872cd85 100644
@@ -325,8 +325,8 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 		printf("CRC32 for %08lx ... %08lx ==> %08lx\n",
 				addr, addr + len - 1, crc);
 
-		if (argc > 3) {
-			ptr = (ulong *)simple_strtoul(argv[3], NULL, 16);
+		if (argc >= 3) {
+			ptr = (ulong *)simple_strtoul(argv[0], NULL, 16);
 			*ptr = crc;
 		}
 	}
Signature · 1 line
1.7.9.5
author
#1 lore raw
Quoted 10 lines · Tom Rini

In the case of not having CONFIG_CMD_HASH but having CONFIG_CMD_CRC32 enabled (and not CONFIG_CRC32_VERIFY), we end up in this part of the code path on hash_command(). However, we will only have exactly 3 args here, and 3 > 3 is false, and we will not try and store the hash at the address given as arg #3. The next problem however is that we've been moving argv around so the third value is now in argv[0] not argv[3].

Confirmed on AM335x Beaglebone White.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131125/5b9d69a9/attachment.pgp>