Skip to contentSkip to conversation

fs: fix FAT name extraction

PATCH In review Patrick Wildt 2 participants 2 messages Nov 26, 2018 – Dec 7, 2018 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/fat/fat.c | 3 +++
 1 file changed, 3 insertions(+)
fs/fat/fat.c +3 -0
index 4bc3030ab88..cadf3d039f0 100644
@@ -810,6 +810,9 @@ static dir_entry *extract_vfat_name(fat_itr *itr)
 
 		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);
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw
Quoted 5 lines · Patrick Wildt

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181207/c766e288/attachment.sig>