[PATCH V2] erofs-utils: fix random data for block-aligned uncompressed file

Huang Jianan huangjianan at oppo.com
Tue Sep 7 13:53:45 AEST 2021


If the file size is block-aligned for uncompressed files, i_u is
meaningless for erofs_inode on disk, but it's not cleared when
datalayout is seted in erofs_prepare_inode_buffer.

This problem will cause inconsistent reproducible builds. Clear the
entire erofs_inode to zero to fix this.

Signed-off-by: Huang Jianan <huangjianan at oppo.com>
---
 lib/inode.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 5bad75e..0cce07d 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -834,25 +834,15 @@ static struct erofs_inode *erofs_new_inode(void)
 	static unsigned int counter;
 	struct erofs_inode *inode;
 
-	inode = malloc(sizeof(struct erofs_inode));
+	inode = calloc(1, sizeof(struct erofs_inode));
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
-	inode->i_parent = NULL;	/* also used to indicate a new inode */
-
 	inode->i_ino[0] = counter++;	/* inode serial number */
 	inode->i_count = 1;
 
 	init_list_head(&inode->i_subdirs);
 	init_list_head(&inode->i_xattrs);
-
-	inode->idata_size = 0;
-	inode->xattr_isize = 0;
-	inode->extent_isize = 0;
-
-	inode->bh = inode->bh_inline = inode->bh_data = NULL;
-	inode->idata = NULL;
-	inode->z_physical_clusterblks = 0;
 	return inode;
 }
 
-- 
2.25.1



More information about the Linux-erofs mailing list