Skip to contentSkip to conversation

fs/squashfs: zero out unused fields in fs_dirent

PATCH In review Heinrich Schuchardt 3 participants 3 messages May 17, 2021 – May 27, 2021 SquashFS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/squashfs: zero out unused fields in fs_dirent

When reading directories the UEFI sub-system must supply file attributes and timestamps. These fields will have to be added to struct fs_dirent. SquashFS should not fill these fields with random data. Ensure that they are zeroed out.

---
 fs/squashfs/sqfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/sqfs.c +1 -1
index 29805c3c6f..997be2dcf4 100644
@@ -876,7 +876,7 @@ int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
 	char **token_list = NULL, *path = NULL;
 	u32 *pos_list = NULL;
 
-	dirs = malloc(sizeof(*dirs));
+	dirs = calloc(1, sizeof(*dirs));
 	if (!dirs)
 		return -EINVAL;
 

--
2.30.2

#1 lore raw

PATCH 1/1 fs/squashfs: zero out unused fields in fs_dirent

Hi Heinrich,

Heinrich Schuchardt <[email protected]> wrote on Mon, 17 May 2021 08:21:39 +0200:

Quoted 24 lines

When reading directories the UEFI sub-system must supply file attributes and timestamps. These fields will have to be added to struct fs_dirent. SquashFS should not fill these fields with random data. Ensure that they are zeroed out.

---
 fs/squashfs/sqfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/sqfs.c +1 -2
index 29805c3c6f..997be2dcf4 100644
@@ -876,7 +876,7 @@ int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
 	char **token_list = NULL, *path = NULL;
 	u32 *pos_list = NULL;
 
-	dirs = malloc(sizeof(*dirs));
+	dirs = calloc(1, sizeof(*dirs));
 	if (!dirs)
 		return -EINVAL;
 
--
Quoted 2 lines

2.30.2

Thanks,
Miqu?l

#2 lore raw
In reply to Heinrich Schuchardt
Quoted 7 lines · Heinrich Schuchardt

When reading directories the UEFI sub-system must supply file attributes and timestamps. These fields will have to be added to struct fs_dirent. SquashFS should not fill these fields with random data. Ensure that they are zeroed out.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom