Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Xm05r-0001U1-04 for mharc-grub-devel@gnu.org; Wed, 05 Nov 2014 07:53:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm05k-0001TF-Q1 for grub-devel@gnu.org; Wed, 05 Nov 2014 07:53:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm05f-0005lb-Ut for grub-devel@gnu.org; Wed, 05 Nov 2014 07:53:40 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:42045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm05f-0005lU-Pm for grub-devel@gnu.org; Wed, 05 Nov 2014 07:53:35 -0500 Received: by mail-wg0-f45.google.com with SMTP id x12so838874wgg.4 for ; Wed, 05 Nov 2014 04:53:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=kXOGYhHjDpJp6GCpXx8JgjRyiHJqZuAVxWPbdZH/tI0=; b=K5+Ahd+Kpc9A9QmB5bp4+Xb0elome2usekmtEcf+vGMFG+JFEH8DZMTxS7R7WqhVKG BlxPLzjA6O539aG/8hBgc9bK81BjN5L1Pk/JJPvsVFoeIRlUg42rXdwr7UsKcfJfDINy d8DFsaLrOzT3lAiwsxmLbAwlZhHwfYsxlcI/ODL5WV/s14LiRT8Nnx+5eC47qlVXlcIK 9+BrDZ88jgGGe6+mRYV9VZ3+Pd2KjjPwiFHTXXLOIRlIq0mJmfJb2gKuaLLq5PbFsDv3 GXeq6CWskGpI+vFXlfI8gEZs8iOjjVD3Fus1N3CIidi3gSD4yedeJS3e8P2AvSxh+RGY kC8Q== X-Gm-Message-State: ALoCoQng+UvKxcV9xF30kS1UP2pTwv4N/8F6B4a/l8u1XO/LcH/sCbqk9v0zIqIzgH80HnxJXyH2 X-Received: by 10.180.102.65 with SMTP id fm1mr5760940wib.16.1415192014626; Wed, 05 Nov 2014 04:53:34 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by mx.google.com with ESMTPSA id h8sm3965900wjs.43.2014.11.05.04.53.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 05 Nov 2014 04:53:33 -0800 (PST) Date: Wed, 5 Nov 2014 12:53:31 +0000 From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH] efi: check *path non-null before grub_strrchr Message-ID: <20141105125331.GB22224@bivouac.eciton.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.45 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Nov 2014 12:53:46 -0000 The EFI version of grub_machine_get_bootlocation crops the boot image name back to the last / in order to get a directory path. However, it does not check that *name is actually set before calling grub_strrchr to do this, and neither does grub_strrchr before dereferencing a NULL pointer. Parent function, grub_set_prefix_and_root, does check the pointer before using. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/init.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index 942ab02..e9c85de 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -63,10 +63,13 @@ grub_machine_get_bootlocation (char **device, char **path) if (!*device && grub_efi_net_config) grub_efi_net_config (image->device_handle, device, path); - /* Get the directory. */ - p = grub_strrchr (*path, '/'); - if (p) - *p = '\0'; + if (*path) + { + /* Get the directory. */ + p = grub_strrchr (*path, '/'); + if (p) + *p = '\0'; + } } void -- 1.7.10.4