From patchwork Sun Apr 28 21:31:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucian Cojocar X-Patchwork-Id: 240308 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 0D8482C00B9 for ; Mon, 29 Apr 2013 07:33:21 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 56E844A1CF; Sun, 28 Apr 2013 23:33:19 +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 ryck7McUa1qz; Sun, 28 Apr 2013 23:33:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CE99D4A1D9; Sun, 28 Apr 2013 23:33:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8EE1D4A1D9 for ; Sun, 28 Apr 2013 23:33:13 +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 7X+7RSXqHuYI for ; Sun, 28 Apr 2013 23:33:09 +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-we0-f171.google.com (mail-we0-f171.google.com [74.125.82.171]) by theia.denx.de (Postfix) with ESMTPS id 88FC84A1CF for ; Sun, 28 Apr 2013 23:33:06 +0200 (CEST) Received: by mail-we0-f171.google.com with SMTP id t57so3032027wey.16 for ; Sun, 28 Apr 2013 14:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=bKk+AYWKDxfdbXUfBxt34yapAPhXo+Dtc0395o/jieo=; b=gddvu7ImpNJG5mooe3awH8hJOmi3TeYZnvqyJgmAtqaqP8ug5cXNVc+tGwi7eyu4+L tLml9+HUawXlI73LU7QtpP+P1HBoPFHpjep0GhyzGuOxkCO3fVraEPmUJvGuQt2LaT7d dlVp67xpUuhaxqeZxsyoGL8kOb9991BotYRjJkwCecCaLCbJUfxNYNOKpD3ktHTyj4e2 XfwUR0P9A62pJ613s8M3W9SK58EL5niEUOmnCwznkZR75FZq53ZqRPNazu7U7cb1prDi 3A8ycBWiajW8hubI9nk1QD1NS/nIvjau0omFyA2PAyFDWwSaUJhw/G2AocJBzBbJCfut lw1Q== X-Received: by 10.180.86.230 with SMTP id s6mr13995543wiz.6.1367184782401; Sun, 28 Apr 2013 14:33:02 -0700 (PDT) Received: from localhost.localdomain (5070811A.static.ziggozakelijk.nl. [80.112.129.26]) by mx.google.com with ESMTPSA id nf9sm16685376wic.3.2013.04.28.14.33.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Apr 2013 14:33:00 -0700 (PDT) From: Lucian Cojocar To: u-boot@lists.denx.de Date: Sun, 28 Apr 2013 23:31:57 +0200 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <20130428090611.C3C49384874@gemini.denx.de> References: <20130428090611.C3C49384874@gemini.denx.de> In-Reply-To: <20130428090611.C3C49384874@gemini.denx.de> References: <20130428090611.C3C49384874@gemini.denx.de> Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v2] env: throw an error when an empty key is used 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 If the environment contains an entry like "=value" "\0" we should throw an error when parsing the environment. Otherwise, U-Boot will enter in an infinite loop. Signed-off-by: Lucian Cojocar --- Changes for v2: - Throw an error instead of silently skip the empty key lib/hashtable.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/hashtable.c b/lib/hashtable.c index 07ebfb2..779580b 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -870,6 +870,12 @@ int himport_r(struct hsearch_data *htab, *sp++ = '\0'; /* terminate value */ ++dp; + if (*name == 0) { + debug("INSERT: unable to use an empty key\n"); + __set_errno(EINVAL); + return 0; + } + /* Skip variables which are not supposed to be processed */ if (!drop_var_from_set(name, nvars, localvars)) continue;