From 0f15824322f8752acf9ece4fc54bf53a7a4e9c57 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 24 Sep 2019 17:51:32 +0200 Subject: Fix zero size stack array allocation in write_inode Simply skip copying of file blocks if there are none. Signed-off-by: David Oberhollenzer --- lib/sqfs/write_inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c index e64e6a6..422959e 100644 --- a/lib/sqfs/write_inode.c +++ b/lib/sqfs/write_inode.c @@ -63,7 +63,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir, ret = sqfs_meta_writer_append(ir, &file, sizeof(file)); if (ret) return ret; - return write_block_sizes(ir, n); + return n->num_file_blocks ? write_block_sizes(ir, n) : 0; } case SQFS_INODE_SLINK: { sqfs_inode_slink_t slink = { @@ -117,7 +117,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir, ret = sqfs_meta_writer_append(ir, &file, sizeof(file)); if (ret) return ret; - return write_block_sizes(ir, n); + return n->num_file_blocks ? write_block_sizes(ir, n) : 0; } case SQFS_INODE_EXT_SLINK: { sqfs_inode_slink_t slink = { -- cgit v1.2.3