public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd_nand: fix crashing bug in nand read/write
@ 2012-06-07 17:19 Steve Sakoman
  2012-06-07 17:27 ` Scott Wood
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Sakoman @ 2012-06-07 17:19 UTC (permalink / raw)
  To: u-boot

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>
---
 common/cmd_nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index fa44295..a91ccf4 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))
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] cmd_nand: fix crashing bug in nand read/write
  2012-06-07 17:19 [U-Boot] [PATCH] cmd_nand: fix crashing bug in nand read/write Steve Sakoman
@ 2012-06-07 17:27 ` Scott Wood
  0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2012-06-07 17:27 UTC (permalink / raw)
  To: u-boot

On 06/07/2012 12:19 PM, Steve Sakoman wrote:
> 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>

Applied to u-boot-nand-flash, thanks!

This was missed in testing because U-Boot on PowerPC unfortunately has a
valid mapping at NULL.

-Scott

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-07 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07 17:19 [U-Boot] [PATCH] cmd_nand: fix crashing bug in nand read/write Steve Sakoman
2012-06-07 17:27 ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox