fs: fix FAT name extraction
The long name apparently can be accumulated using multiple
13-byte slots. Unfortunately we never checked how many we
can actually fit in the buffer we are reading to.
Signed-off-by: Patrick Wildt <patrick@blueri.se>
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index e0c0767..ac8913e 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -821,6 +821,9 @@
slot2str((dir_slot *)dent, buf, &idx);
+ if (n + idx >= sizeof(itr->l_name))
+ return NULL;
+
/* shift accumulated long-name up and copy new part in: */
memmove(itr->l_name + idx, itr->l_name, n);
memcpy(itr->l_name, buf, idx);