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

Stefan Agner stefan at agner.ch
Mon Jul 1 21:16:58 CEST 2013


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 at agner.ch>
---
  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;
-- 
1.8.3.1





More information about the U-Boot mailing list