diff mbox series

[1/1] fs/squashfs: zero out unused fields in fs_dirent

Message ID 20210517062139.101617-1-xypron.glpk@gmx.de
State Accepted
Commit 53ba2c21c2df142b37bb2f0d6850d79dcfd8976f
Delegated to: Tom Rini
Headers show
Series [1/1] fs/squashfs: zero out unused fields in fs_dirent | expand

Commit Message

Heinrich Schuchardt May 17, 2021, 6:21 a.m. UTC
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.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 fs/squashfs/sqfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.30.2

Comments

Miquel Raynal May 17, 2021, 7:10 a.m. UTC | #1
Hi Heinrich,

Heinrich Schuchardt <xypron.glpk@gmx.de> wrote on Mon, 17 May 2021
08:21:39 +0200:

> 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.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  fs/squashfs/sqfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
> index 29805c3c6f..997be2dcf4 100644
> --- a/fs/squashfs/sqfs.c
> +++ b/fs/squashfs/sqfs.c
> @@ -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
> 

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl
Tom Rini May 27, 2021, 11:42 a.m. UTC | #2
On Mon, May 17, 2021 at 08:21:39AM +0200, Heinrich Schuchardt wrote:

> 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.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

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

Patch

diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 29805c3c6f..997be2dcf4 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -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;