diff mbox series

[U-Boot,v2,3/4] fs/fat: Fix pathnames using '..' that lead to the root directory

Message ID 20170925190634.21738-3-tuomas.tynkkynen@iki.fi
State Accepted
Delegated to: Tom Rini
Headers show
Series [U-Boot,v2,1/4] fs/ext4: Fix group descriptor checksum calculation | expand

Commit Message

Tuomas Tynkkynen Sept. 25, 2017, 7:06 p.m. UTC
If we end up back in the root directory via a '..' directory entry, set
itr->is_root accordingly. Failing to do that gives spews like
"Invalid FAT entry" and being unable to access directory entries located
past the first cluster of the root directory.

Fixes: 8eafae209c35 ("fat/fs: convert to directory iterators")
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
---
v2: Add Reviewed-by
---
 fs/fat/fat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tom Rini Oct. 7, 2017, 1:08 p.m. UTC | #1
On Mon, Sep 25, 2017 at 10:06:33PM +0300, Tuomas Tynkkynen wrote:

> If we end up back in the root directory via a '..' directory entry, set
> itr->is_root accordingly. Failing to do that gives spews like
> "Invalid FAT entry" and being unable to access directory entries located
> past the first cluster of the root directory.
> 
> Fixes: 8eafae209c35 ("fat/fs: convert to directory iterators")
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 36a309c73c..3d3e17e8fa 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -710,13 +710,14 @@  static void fat_itr_child(fat_itr *itr, fat_itr *parent)
 	itr->fsdata = parent->fsdata;
 	if (clustnum > 0) {
 		itr->clust = clustnum;
+		itr->is_root = 0;
 	} else {
 		itr->clust = parent->fsdata->root_cluster;
+		itr->is_root = 1;
 	}
 	itr->dent = NULL;
 	itr->remaining = 0;
 	itr->last_cluster = 0;
-	itr->is_root = 0;
 }
 
 static void *next_cluster(fat_itr *itr)