Patchwork [U-Boot,2/3] btrfs: Fix crash while path parsing

login
register
mail settings
Submitter Stefan Agner
Date July 1, 2013, 7:16 p.m.
Message ID <93c41d7035269076fd5ae0e33805a6e1@agner.ch>
Download mbox | patch
Permalink /patch/256211/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Stefan Agner - July 1, 2013, 7:16 p.m.
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 <stefan@agner.ch>
---
  fs/btrfs/btrfs.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Patch

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;