Re: [U-Boot] [PATCH 08/12] env: Check for NULL pointer in envmatch()

2012-08-17 Thread Mike Frysinger
On Friday 17 August 2012 16:49:42 Joe Hershberger wrote:
> If the pointer passed into envmatch() is NULL, return -1 instead of
> crashing.

so don't pass in NULL ?
-mike


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 08/12] env: Check for NULL pointer in envmatch()

2012-08-17 Thread Joe Hershberger
If the pointer passed into envmatch() is NULL, return -1 instead of
crashing.

Signed-off-by: Joe Hershberger 
---
 common/cmd_nvedit.c | 3 +++
 tools/env/fw_env.c  | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index bd52fa4..76cdd87 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -619,6 +619,9 @@ U_BOOT_CMD(
  */
 int envmatch(uchar *s1, int i2)
 {
+   if (s1 == NULL)
+   return -1;
+
while (*s1 == env_get_char(i2++))
if (*s1++ == '=')
return i2;
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 9ecc22a..23cf241 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1072,6 +1072,8 @@ exit:
 
 static char *envmatch (char * s1, char * s2)
 {
+   if (s1 == NULL || s2 == NULL)
+   return NULL;
 
while (*s1 == *s2++)
if (*s1++ == '=')
-- 
1.7.11.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot