Skip to contentSkip to conversation

fs: fat: avoid out of bounds access warning

PATCH New Heinrich Schuchardt 2 participants 2 messages Jan 25, 2021 – Jan 30, 2021 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: fat: avoid out of bounds access warning

When copying short name plus extension refer to the encapsulating structure and not to the short name element.

---
 fs/fat/fat_write.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/fat/fat_write.c +2 -5
index 0132ef9b42..aae3a6a3d1 100644
@@ -108,10 +108,7 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
 	char buf[13];
 	int i;
 	int ret;
-	struct {
-		char name[8];
-		char ext[3];
-	} dirent;
+	struct nameext dirent;
 
 	if (!filename)
 		return -EIO;
@@ -185,7 +182,7 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
 	}
 	return -EIO;
 out:
-	memcpy(shortname, dirent.name, SHORT_NAME_SIZE);
+	memcpy(shortname, &dirent, SHORT_NAME_SIZE);
 	return ret;
 }
 

--
2.29.2

#1 lore raw

PATCH 1/1 fs: fat: avoid out of bounds access warning

Quoted 4 lines · Heinrich Schuchardt

When copying short name plus extension refer to the encapsulating structure and not to the short name element.

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: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210130/2fd53893/attachment.sig>