]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
printenv: Correct out-of-memory condition check.
authorMaxime Larocque <maxmtl2002@yahoo.ca>
Fri, 28 Sep 2012 05:00:13 +0000 (05:00 +0000)
committerTom Rini <trini@ti.com>
Wed, 17 Apr 2013 14:58:14 +0000 (10:58 -0400)
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>
common/cmd_nvedit.c

index afa128ece2d1ed3405f73ea1c9837adde882ddee..68b0f4f6d809b36e8e8b91a87ad07e4c21473c09 100644 (file)
@@ -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;
 }