From patchwork Fri Oct 5 10:46:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerlando Falauto X-Patchwork-Id: 189456 X-Patchwork-Delegate: trini@ti.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 8F60A2C0093 for ; Fri, 5 Oct 2012 20:46:25 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DDDF62808C; Fri, 5 Oct 2012 12:46: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 H1uSBBhHwpTs; Fri, 5 Oct 2012 12:46:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D37932807E; Fri, 5 Oct 2012 12:46:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C47922807E for ; Fri, 5 Oct 2012 12:46:18 +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 dDlH6WyxXvSb for ; Fri, 5 Oct 2012 12:46:18 +0200 (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 mail-de.keymile.com (mail-de.keymile.com [195.8.104.1]) by theia.denx.de (Postfix) with SMTP id 22B2D2805F for ; Fri, 5 Oct 2012 12:46:16 +0200 (CEST) Received: from mailrelay.de.keymile.net ([10.9.1.54]) by eSafe SMTP Relay 1349421691; Fri, 05 Oct 2012 12:46:16 +0200 Received: from chber1-10555x.ch.keymile.net (chber1-10555x.ch.keymile.net [172.31.40.82]) by mailrelay.de.keymile.net (8.12.2/8.12.2) with ESMTP id q95Aixj8022110; Fri, 5 Oct 2012 12:45:00 +0200 (MEST) From: Gerlando Falauto To: sbabic@denx.de, u-boot@lists.denx.de Date: Fri, 5 Oct 2012 12:46:10 +0200 Message-Id: <1349433970-16689-1-git-send-email-gerlando.falauto@keymile.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <506EB964.4030902@denx.de> References: <506EB964.4030902@denx.de> X-ESAFE-STATUS: [srvhellgate.de.keymile.net] Mail clean Cc: trini@ti.com, Gerlando Falauto Subject: [U-Boot] [PATCH] env: fix crash using default -f -a 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de env default -a -f calls env_check_apply on all existing environment variables with a NULL value for "newval" as a way of cleaning up. This causes string manipulation functions to crash on most architectures. So replace a NULL argument with an empty string. Reported-By: Stefano Babic Signed-off-by: Gerlando Falauto Tested-by: Stefano Babic --- common/cmd_nvedit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 3474bc6..c38b475 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -213,6 +213,9 @@ int env_check_apply(const char *name, const char *oldval, { int console = -1; + /* Default value for NULL to protect string-manipulating functions */ + newval = newval ? : ""; + /* Check for console redirection */ if (strcmp(name, "stdin") == 0) console = stdin;