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 91FB5C11F64 for ; Mon, 28 Jun 2021 19:49:14 +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 69CCB61CA1 for ; Mon, 28 Jun 2021 19:49:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69CCB61CA1 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 9AD9D82E4C; Mon, 28 Jun 2021 21:48:59 +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="EXZNIOHy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A3D982E1A; Mon, 28 Jun 2021 21:39:33 +0200 (CEST) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 7D8BF82E0F for ; Mon, 28 Jun 2021 21:39:29 +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-x430.google.com with SMTP id i94so22695250wri.4 for ; Mon, 28 Jun 2021 12:39:29 -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=EXZNIOHy3mEcaU8LKrPwuPrB0fEUfTkGK3aLcwNvMbI6g7zdCQxZVMzn8HjHwEcDxZ 0KerA4Rj89K5i+yFX+aMmLl7EB6Yd6zlKV6IC8KfTwLPtn93K0B0veqF1+ISSW+NC0zu PtHvHqNz1GD/6xBuCd0tHSayZ3cFl5DS+tOnM= 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=Yyex76ejFXdMovHjSbJxPfL5YVSLGmaxiMtDvIC4ZhMDU4mYHF2gDeDcAqbeJpLjaz cwcA1QGNnManTkfmxb/YKChj9olFAQFN2Ah+9HjW6rHREUOItAGm1ZrqZby2ba7q0WWo jw1cqrSZmP3G20QEw8Kk4eO6QVUcCdVnpklmX+FlEKRiCpQ6P/8y/+Tq4EijK8ppJsp3 qMqybqJfs6r9u6qKl6qFWv6vqzlY2hiFxH1RZQ0gkYpXopVBzN8vq0aghavn46MPKgTV yimLnbt+3+c0evfvM5HxVJ77EZq6rX07Fj4asCc0oft+2kFasayN6w+BCHGqR9wu92UH VhJw== X-Gm-Message-State: AOAM531bVaeQmyD/L4JOnW1CJXZirzRNtrbigq5FFdViTWdARl0raN6g S9kFguvYhI7peElnae2r5RxbAISZDVCybobf X-Google-Smtp-Source: ABdhPJwJR7aXV4xlJFU99KpSnBllr0tvn2xgNDgmzt2xDcEhYI5Er65kVwP3fLkRAcqsj9VG3mZCZg== X-Received: by 2002:a5d:6da1:: with SMTP id u1mr22432955wrs.281.1624909169177; Mon, 28 Jun 2021 12:39:29 -0700 (PDT) Received: from pwmachine.home ([2a01:cb14:983:1f00:73d:36ac:5ef7:7feb]) by smtp.gmail.com with ESMTPSA id o17sm400660wmh.19.2021.06.28.12.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 12:39:28 -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:39:15 +0200 Message-Id: <20210628193915.797459-2-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210628193915.797459-1-francis.laniel@amarulasolutions.com> References: <20210628193915.797459-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