From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Larocque Date: Fri, 28 Sep 2012 11:00:13 -0400 Subject: [U-Boot] [PATCH] printenv show garbage on out-of-memory conditions Message-ID: <5065BB7D.3010806@yahoo.ca> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello, 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. Does not seem to be critical, but it is misleading when debugging a OOM error... I have added a printf to display something in case of error; I'll leave it to the committer to keep it or remove it. Found in U-Boot 2011.12, but still present in current git. Maxime Larocque Signed-off-by: Maxime Larocque --- common/cmd_nvedit.c +++ common/cmd_nvedit.c @@ -110,7 +110,7 @@ static int env_print(char *name) { char *res = NULL; - size_t len; + ssize_t len; if (name) { /* print a single name */ ENTRY e, *ep; @@ -132,6 +132,9 @@ free(res); return len; } + else { + printf("## Error: cannot export environment\n"); + } /* should never happen */ return 0;