From patchwork Fri Sep 28 15:00:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Larocque X-Patchwork-Id: 188194 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8F3832C00BA for ; Mon, 1 Oct 2012 05:35:46 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C2CC28098; Sun, 30 Sep 2012 21:35:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Rb2lY9N3dVlk; Sun, 30 Sep 2012 21:35:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C664F2808D; Sun, 30 Sep 2012 21:34:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BE90F280A5 for ; Fri, 28 Sep 2012 19:14:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ynbULc45nEYy for ; Fri, 28 Sep 2012 19:14:05 +0200 (CEST) X-Greylist: delayed 8025 seconds by postgrey-1.27 at theia; Fri, 28 Sep 2012 19:14:02 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from gator378.hostgator.com (gator378.hostgator.com [184.173.199.219]) by theia.denx.de (Postfix) with ESMTPS id 292D72809E for ; Fri, 28 Sep 2012 19:14:02 +0200 (CEST) Received: from [173.231.110.50] (port=32673 helo=[192.168.10.210]) by gator378.hostgator.com with esmtpa (Exim 4.77) (envelope-from ) id 1THc33-0008Gr-Uf for u-boot@lists.denx.de; Fri, 28 Sep 2012 10:00:13 -0500 Message-ID: <5065BB7D.3010806@yahoo.ca> Date: Fri, 28 Sep 2012 11:00:13 -0400 From: Maxime Larocque User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: u-boot@lists.denx.de X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator378.hostgator.com X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - yahoo.ca X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.10.210]) [173.231.110.50]:32673 X-Source-Auth: max@weirdows.com X-Email-Count: 1 X-Source-Cap: bWF4bXRsO21heG10bDtnYXRvcjM3OC5ob3N0Z2F0b3IuY29t X-Mailman-Approved-At: Sun, 30 Sep 2012 21:34:46 +0200 Subject: [U-Boot] [PATCH] printenv show garbage on out-of-memory conditions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@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;