Skip to contentSkip to conversation

btrfs: Fix crash while path parsing

PATCH New Stefan Agner 1 participant 1 message Jul 1, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 btrfs: Fix crash while path parsing

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).

---
  fs/btrfs/btrfs.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/btrfs.c +3 -3
index a7fcc16..e4dfd67 100644
@@ -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;
Signature · 1 line
1.8.3.1