summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Larocque <maxmtl2002@yahoo.ca>2012-09-28 05:00:13 +0000
committerTom Rini <trini@ti.com>2013-04-17 10:58:14 -0400
commit22a4a6c5c2ea4c5998b98e6358b351848f2b765f (patch)
tree73e38e30134e12ea0e8b913e0ec653351c835aa4
parent314dd4fecc87175f6e79eb977966fb60b33c543c (diff)
downloadu-boot-imx-22a4a6c5c2ea4c5998b98e6358b351848f2b765f.zip
u-boot-imx-22a4a6c5c2ea4c5998b98e6358b351848f2b765f.tar.gz
u-boot-imx-22a4a6c5c2ea4c5998b98e6358b351848f2b765f.tar.bz2
printenv: Correct out-of-memory condition check.
In common/cmd_nvedit.c, en env_print(), the wrong type is used for len. hexport_r() returns -1 on error (like OOM), which is converted to 0xffffffff when put in an unsigned. Said value is obviously bigger then 0, and as a result an uninitialized string is then displayed. Other usages of hexport_r() in the code correctly uses ssize_t to keep its return value. Signed-off-by: Maxime Larocque <maxmtl2002@yahoo.ca>
-rw-r--r--common/cmd_nvedit.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index afa128e..68b0f4f 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -96,7 +96,7 @@ int get_env_id(void)
static int env_print(char *name, int flag)
{
char *res = NULL;
- size_t len;
+ ssize_t len;
if (name) { /* print a single name */
ENTRY e, *ep;
@@ -120,6 +120,7 @@ static int env_print(char *name, int flag)
}
/* should never happen */
+ printf("## Error: cannot export environment\n");
return 0;
}