]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
cmd_nand: fix crashing bug in nand read/write
authorSteve Sakoman <steve@sakoman.com>
Thu, 7 Jun 2012 17:19:18 +0000 (10:19 -0700)
committerScott Wood <scott@tyr.buserror.net>
Fri, 8 Jun 2012 19:57:24 +0000 (14:57 -0500)
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 <steve@sakoman.com>
Signed-off-by: Scott Wood <scott@tyr.buserror.net>
common/cmd_nand.c

index fa442951d811a33dc1c5affd94d7a95975e08936..a91ccf4df37f6f6bb6b69f5453d2efded777db30 100644 (file)
@@ -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))