Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j6ZI2-00045q-Sw for mharc-grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55587) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ZHy-0003sX-NE for grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6ZHw-0006Yj-N8 for grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:13 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:27510 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6ZHw-0006Yc-JR for grub-devel@gnu.org; Tue, 25 Feb 2020 07:26:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582633572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XqJJSmBgL3OheS+0Y7hqR0wwRGPPAZvL0WAGmTiQvPo=; b=dVeMPJ7jykTLtm+uBu2hpVWnFbq8hwkHEb7WScbHrWdi11FfPA0nlo+OO7GbcNrwdg1RIC 7h9wjEZVy0eb41Hu87lSC72ZlFIK9S5leBJYOwuqgqcbFSUDr+tIc4Ss7nsXM+KXziRtnI eK5z1V7Ob02Tvi4eW+oOtR925Jr8xJE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-TFl4yeG1N26mQf1jgdBRJQ-1; Tue, 25 Feb 2020 07:26:10 -0500 X-MC-Unique: TFl4yeG1N26mQf1jgdBRJQ-1 Received: by mail-wr1-f69.google.com with SMTP id d15so7232199wru.1 for ; Tue, 25 Feb 2020 04:26:10 -0800 (PST) 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=97Pnou7GdVvTHkk/02XWFGNbSYCGfrDj2pPhf5tTXwU=; b=QOT2NLWuXZDX2XcaGEiF0x7CXZP330vMtl+YosbKRXijb+obWsEuR74McpmAhotGJ3 KGEDq5oWt6G+UW3W+iNmMrpuY1Y33QWvQww6rRIFAkmuS1Xp7GOtPhvPUQdDvc2MdY7w 3uNjwGrMS+GLKOQYDzS7Tct9D4cqXrXSIWcOS+QF0qyiPqyzxOpu+thhnk3n8glMP7pK Y3jh78cOB3hnnLO486DIMQgCMmndLwodkcOMbX1gCl3wBgV/LeF+XrJ+YL2H2AQ+Nwi5 xsxdd0ii97apwyixAjd4rRquXihA9chPjdShFr7OUcXwHSlNrFgzKuBo+0RLgqJ3q6/c Wo1Q== X-Gm-Message-State: APjAAAUE/rp3q4gQwYcqiqPCuJ+UCCdt9t/iHN6ueK+w7csJJkzqoBVc T0Rb32MgRySIEgxEzvUF4ROECWlTs5gsH9NtCs3pPE07t6om8JOR6xAvwwYhSLK5NjXjGsfzBWl TvMIL2pvCLYg= X-Received: by 2002:a1c:e483:: with SMTP id b125mr5214635wmh.187.1582633568878; Tue, 25 Feb 2020 04:26:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzd3EEwt8J2nxMrIygjh+WyzVaq2bVtdT82wekeeAFDlxgwk9jeC8k1KM5nwReueDJQg+cEEA== X-Received: by 2002:a1c:e483:: with SMTP id b125mr5214619wmh.187.1582633568692; Tue, 25 Feb 2020 04:26:08 -0800 (PST) Received: from minerva.redhat.com ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id q6sm17251653wrf.67.2020.02.25.04.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 04:26:08 -0800 (PST) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Daniel Kiper , Peter Jones , Javier Martinez Canillas Subject: [PATCH 05/10] normal/completion: Fix possible NULL pointer dereference Date: Tue, 25 Feb 2020 13:25:48 +0100 Message-Id: <20200225122553.1120216-6-javierm@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200225122553.1120216-1-javierm@redhat.com> References: <20200225122553.1120216-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Feb 2020 12:26:16 -0000 From: Peter Jones Coverity Scan reports that the grub_strrchr() function can return NULL if the character is not found. Check if that's the case for dirfile pointer. Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas --- grub-core/normal/completion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c index 596102848c1..c07100a8de3 100644 --- a/grub-core/normal/completion.c +++ b/grub-core/normal/completion.c @@ -284,7 +284,8 @@ complete_file (void) =20 /* Cut away the filename part. */ dirfile =3D grub_strrchr (dir, '/'); - dirfile[1] =3D '\0'; + if (dirfile) +=09dirfile[1] =3D '\0'; =20 /* Iterate the directory. */ (fs->fs_dir) (dev, dir, iterate_dir, NULL); --=20 2.24.1