public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1] env: fix crash using default -f -a
@ 2012-10-04 17:30 Stefano Babic
  2012-10-04 21:57 ` Tom Rini
  2012-10-05 10:29 ` Gerlando Falauto
  0 siblings, 2 replies; 9+ messages in thread
From: Stefano Babic @ 2012-10-04 17:30 UTC (permalink / raw)
  To: u-boot

newval pointer is not checked before its usage,
inside env_check_apply().

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: gerlando.falauto at keymile.com
---
 common/cmd_nvedit.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 3474bc6..8144c85 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -272,7 +272,7 @@ int env_check_apply(const char *name, const char *oldval,
 		/*
 		 * Switch to new baudrate if new baudrate is supported
 		 */
-		if (strcmp(name, "baudrate") == 0) {
+		if ((strcmp(name, "baudrate") == 0) && (newval != NULL)) {
 			int baudrate = simple_strtoul(newval, NULL, 10);
 			int i;
 			for (i = 0; i < N_BAUDRATES; ++i) {
@@ -308,12 +308,12 @@ int env_check_apply(const char *name, const char *oldval,
 	 * Some variables should be updated when the corresponding
 	 * entry in the environment is changed
 	 */
-	if (strcmp(name, "loadaddr") == 0) {
+	if ((strcmp(name, "loadaddr") == 0) && (newval != NULL)) {
 		load_addr = simple_strtoul(newval, NULL, 16);
 		return 0;
 	}
 #if defined(CONFIG_CMD_NET)
-	else if (strcmp(name, "bootfile") == 0) {
+	else if ((strcmp(name, "bootfile") == 0) && (newval != NULL)) {
 		copy_filename(BootFile, newval, sizeof(BootFile));
 		return 0;
 	}
-- 
1.7.9.5

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

end of thread, other threads:[~2012-10-05 22:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04 17:30 [U-Boot] [PATCH v1] env: fix crash using default -f -a Stefano Babic
2012-10-04 21:57 ` Tom Rini
2012-10-05 10:29 ` Gerlando Falauto
2012-10-05 10:41   ` Stefano Babic
2012-10-05 10:46     ` [U-Boot] [PATCH] " Gerlando Falauto
2012-10-05 11:50       ` Stefano Babic
2012-10-05 22:26       ` Tom Rini
2012-10-05 10:58     ` [U-Boot] [PATCH v1] " Gerlando Falauto
2012-10-05 11:49       ` Stefano Babic

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