Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gjq1g-0005N1-TF for mharc-grub-devel@gnu.org; Wed, 16 Jan 2019 13:34:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjq1f-0005LM-6A for grub-devel@gnu.org; Wed, 16 Jan 2019 13:34:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjq1e-0001hj-Hm for grub-devel@gnu.org; Wed, 16 Jan 2019 13:34:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gjq1e-0001h6-Ch for grub-devel@gnu.org; Wed, 16 Jan 2019 13:34:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97E60D4E56; Wed, 16 Jan 2019 18:34:53 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 968BA5D967; Wed, 16 Jan 2019 18:34:52 +0000 (UTC) From: Prarit Bhargava To: grub-devel@gnu.org Cc: Prarit Bhargava , mleitner@redhat.com, pjones@redhat.com, javierm@redhat.com, aruiz@redhat.com, Daniel Kiper Subject: [PATCH v2 1/3] grub-editenv: Verify the variable size Date: Wed, 16 Jan 2019 13:34:41 -0500 Message-Id: <20190116183443.14978-2-prarit@redhat.com> In-Reply-To: <20190116183443.14978-1-prarit@redhat.com> References: <20190116183443.14978-1-prarit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 16 Jan 2019 18:34:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2019 18:34:56 -0000 It is possible to execute 'grub-editenv - set ="some data"', which results in an unremoveable entry ="some data" Verify the variable has a size before setting a value. Signed-off-by: Prarit Bhargava Cc: mleitner@redhat.com Cc: pjones@redhat.com Cc: javierm@redhat.com Cc: aruiz@redhat.com Cc: Daniel Kiper --- util/grub-editenv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/grub-editenv.c b/util/grub-editenv.c index 118e89fe57fe..0b6c69b9688c 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -217,6 +217,9 @@ set_variables (const char *name, int argc, char *argv[]) *(p++) = 0; + if (! grub_strlen(argv[0])) + grub_util_error (_("No parameter specified")); + if (! grub_envblk_set (envblk, argv[0], p)) grub_util_error ("%s", _("environment block too small")); -- 2.17.2