From patchwork Mon Jul 1 19:16:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 256211 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 01C1F2C008F for ; Tue, 2 Jul 2013 05:35:16 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A92B14A111; Mon, 1 Jul 2013 21:35:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zYHbcTrl0y2U; Mon, 1 Jul 2013 21:35:03 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 78E0D4A112; Mon, 1 Jul 2013 21:34:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 888CA4A025 for ; Mon, 1 Jul 2013 21:23:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VA7zT32q5NG2 for ; Mon, 1 Jul 2013 21:23:46 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.kmu-office.ch (mail.kmu-office.ch [178.209.48.102]) by theia.denx.de (Postfix) with ESMTP id 48FF74A0B0 for ; Mon, 1 Jul 2013 21:23:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.kmu-office.ch (Postfix) with ESMTP id BD3D7337641 for ; Mon, 1 Jul 2013 21:16:12 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kmu-office.ch Received: from mail.kmu-office.ch ([127.0.0.1]) by localhost (mail.kmu-office.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O5tOQA+CRP2V for ; Mon, 1 Jul 2013 21:16:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.kmu-office.ch (Postfix) with ESMTP id 7A000337685 for ; Mon, 1 Jul 2013 21:16:12 +0200 (CEST) Received: from webmail.kmu-office.ch (unknown [178.209.48.103]) (Authenticated sender: stefan@agner.ch) by mail.kmu-office.ch (Postfix) with ESMTPSA id 5F37B337641 for ; Mon, 1 Jul 2013 21:16:12 +0200 (CEST) MIME-Version: 1.0 Date: Mon, 01 Jul 2013 21:16:58 +0200 From: Stefan Agner To: u-boot@lists.denx.de Message-ID: <93c41d7035269076fd5ae0e33805a6e1@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/0.9.1 X-Mailman-Approved-At: Mon, 01 Jul 2013 21:34:37 +0200 Subject: [U-Boot] [PATCH 2/3] btrfs: Fix crash while path parsing X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de When parsing a path with a leading slash, the root inode was freed which lead to a crash. Path parsing is now improved and allows leading slashs like other filesystem commands (e.g. ext4load). Signed-off-by: Stefan Agner --- fs/btrfs/btrfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c index a7fcc16..e4dfd67 100644 --- a/fs/btrfs/btrfs.c +++ b/fs/btrfs/btrfs.c @@ -963,6 +963,9 @@ int searchdir(const char *name) if (!pathbuf) goto err; + while (*p == '/') + p++; + do { got_link: if (*p == '/') { @@ -1324,9 +1327,6 @@ int btrfs_ls(const char *dirn) char *dirname = (char *)dirn; struct _DIR_ *dir; - if (*dirname == '/' && *(dirname+1) == 0) - *dirname = '.'; - dir = opendir(dirname); if (dir == NULL) return -1;