Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAD1EC11F64 for ; Mon, 28 Jun 2021 19:48:58 +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 A284161CA1 for ; Mon, 28 Jun 2021 19:48:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A284161CA1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E965782E16; Mon, 28 Jun 2021 21:48:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="UjICLHhr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 08F3182E0B; Mon, 28 Jun 2021 21:32:17 +0200 (CEST) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0C65E82E0D for ; Mon, 28 Jun 2021 21:32:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francis.laniel@amarulasolutions.com Received: by mail-wr1-x42c.google.com with SMTP id j1so22595271wrn.9 for ; Mon, 28 Jun 2021 12:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aNOmpKJE8oINGNksJvcBmq3Yw86BpsS5VeEYCcxiKcQ=; b=UjICLHhrhT2FI4g+8cePOoMKtjApUl+hgGP5mkjUPRTMHlMu89qW6f7EX572xPLsO0 D7s3xZAZUkhLa4Cp5om+fXHE+uHMaMBmGh3ALOf+PjwE8mfHhYrwjV0cPXyXsWFfpKDi q8JvjGnVaJDiL65SCqIMwu16KiSz6lV0LJdek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aNOmpKJE8oINGNksJvcBmq3Yw86BpsS5VeEYCcxiKcQ=; b=gBmd6Q+Ae32Fr6Zxbd0RlqA77mtsyvQDwtdUXgUTUoRuv9JD6GKSKFqF0eMspf6P2p MmgBbhT9sEH56varJnInpfLDA+iSerPJxXeh5bQRu8lrTza94GVizlurWDV4feiqa75M SefCYtWDLY2X3Dnq8euntynPP3/qhnsFQCFwvT3771AfozEkTxEtfJ8OMisIMNOqql+w HMPIAXR/URvw7La22MYK1cirJXSrVGS6zE+0tQU3DnTgnt04K9ekDnFR22Fx/0eDuDn9 1n2sXyBKHnGQEqIKslgfzR+yAJWiDfo1Ayfn9SRTgXDhZhKSJGQDruuusmpG/s5b5EPJ fC5g== X-Gm-Message-State: AOAM5324X+ZDk5C4uLsp1CvJ5eMeqOCYGkQEigfxKCKcOFvxgxxuz2Dt l89V0+oLfoaKIDEOUcBRa4pAy4P1gjZ94Spn X-Google-Smtp-Source: ABdhPJxwiOwT70+1zPQ3mYspfFQKYKZzmWsL1Y5pUKDaBbTYcnbxvRdH0wMGsomcBUBgdjRIEMPX6A== X-Received: by 2002:adf:ef8b:: with SMTP id d11mr10146956wro.346.1624908729639; Mon, 28 Jun 2021 12:32:09 -0700 (PDT) Received: from pwmachine.home ([2a01:cb14:983:1f00:73d:36ac:5ef7:7feb]) by smtp.gmail.com with ESMTPSA id i2sm1631167wmq.42.2021.06.28.12.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 12:32:09 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de, joe.hershberger@ni.com, wd@denx.de Cc: michael@amarulasolutions.com, ondrej@amarulasolutions.com, Francis Laniel Subject: [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty. Date: Mon, 28 Jun 2021 21:31:45 +0200 Message-Id: <20210628193145.796999-2-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210628193145.796999-1-francis.laniel@amarulasolutions.com> References: <20210628193145.796999-1-francis.laniel@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 28 Jun 2021 21:48:54 +0200 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 Before this patch, it was possible to do the following using setenv: setenv '' foo Then, on next reboot, U-Boot will not be able to parse environment due to it having: =foo Now, if the above command is given, an error message is thrown and environment is not modified. Signed-off-by: Francis Laniel --- cmd/nvedit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index d14ba10cef..64b7aef78d 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -262,6 +262,11 @@ static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) return 1; } + if (!strlen(name)) { + printf("## Error: variable name cannot be empty\n"); + return 1; + } + env_id++; /* Delete only ? */ -- 2.25.1