Skip to content

Commit 2127799

Browse files
committed
cfs-fuse: Avoid UB with listxattr
Ensure we don't attempt to alloca() a zero sized array. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 09970db commit 2127799

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/cfs-fuse.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ static void cfs_listxattr(fuse_req_t req, fuse_ino_t ino, size_t max_size)
741741
uint32_t raw_blkaddr;
742742
size_t isize;
743743
size_t xattr_size;
744-
char buf[max_size];
744+
// This must be nonzero to avoid undefined behavior
745+
char buf[max_size > 0 ? max_size : 1];
745746
size_t buf_size;
746747
uint8_t shared_count;
747748
const struct erofs_xattr_ibody_header *xattr_header;

0 commit comments

Comments
 (0)