From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36ABCC433EF for ; Sun, 17 Oct 2021 15:38:39 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F19060ED5 for ; Sun, 17 Oct 2021 15:38:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F19060ED5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4640183318; Sun, 17 Oct 2021 17:37:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ccEoV/BO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CF9B8331E; Sun, 17 Oct 2021 17:37:08 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 70A7B8342C for ; Sun, 17 Oct 2021 17:36:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 1863D60E74; Sun, 17 Oct 2021 15:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634485013; bh=3KtbTd8SNvV3K6d5VL6qEhQGKaiHM6mYhfoa2W4jaL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ccEoV/BOyL8WdpmLj+OBGfmFU7mjngE1aDuZGeu8UsKeyn27W8Xb6YgkRubzE+cq8 ferpgNYhxcrXJ0XPT39igzhshQoyYevbS1Rn4OAjhbIdK1TP13Sq75noLsUUjXVbfH GyNXmdAEDsj3h6IgnRVT+ccGmJn7j4YCU/lxL9mVlOH0YO6+Et3v528S1pRl+RWlPD EMX28ONP50ODWERXvJ4JIvP6aNrkQqYlnAjxlOrqEyUoSDHc07a9NxuLoLP5JZfdJt HbTa9zWx/+pTsyJeDTtlpzV84SWhy3ngmpdwMyOT+zi+DmOt7UXY/8UX/P/s1E9gTS EvR6PTf3MnsEQ== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Simon Glass , Tom Rini Cc: U-Boot Mailing List , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH v3 09/13] env: Early return from env_get_f() on NULL name Date: Sun, 17 Oct 2021 17:36:34 +0200 Message-Id: <20211017153638.29870-10-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211017153638.29870-1-kabel@kernel.org> References: <20211017153638.29870-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Marek BehĂșn Test non-NULL name immediately, not in env_match(). Signed-off-by: Marek BehĂșn Reviewed-by: Simon Glass --- cmd/nvedit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 8d53579d92..063cc76282 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -708,9 +708,6 @@ char *from_env(const char *envvar) static const char *env_match(const char *p, const char *s1) { - if (s1 == NULL || *s1 == '\0') - return NULL; - while (*s1 == *p++) if (*s1++ == '=') return p; @@ -728,6 +725,9 @@ int env_get_f(const char *name, char *buf, unsigned len) { const char *env, *p, *end; + if (name == NULL || *name == '\0') + return -1; + if (gd->env_valid == ENV_INVALID) env = (const char *)default_environment; else -- 2.32.0