From 8d75c8964baa76d097edb4aa4b0474600f2998ba Mon Sep 17 00:00:00 2001 From: Steve Sakoman Date: Thu, 7 Jun 2012 10:19:18 -0700 Subject: [PATCH] cmd_nand: fix crashing bug in nand read/write Commit 418396e212b59bf907dbccad997ff50f7eb61b16 introduced a bug that causes nand read and nand write to crash in strcmp due to a null pointer. Root cause is that strchr(cmd, '.') returns a null pointer when the input string does not contain a '.' The strcmp function does not check for null pointers, resulting in a crash. Signed-off-by: Steve Sakoman Signed-off-by: Scott Wood --- common/cmd_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cmd_nand.c b/common/cmd_nand.c index fa442951d8..a91ccf4df3 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -617,7 +617,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) s = strchr(cmd, '.'); - if (!strcmp(s, ".raw")) { + if (s && !strcmp(s, ".raw")) { raw = 1; if (arg_off(argv[3], &dev, &off, &size)) -- 2.25.1