Skip to content

Commit 77618db

Browse files
committed
zstd: Fix array-index-out-of-bounds UBSAN warning
Zstd used an array of length 1 to mean a flexible array for C89 compatibility. Switch to a C99 flexible array to fix the UBSAN warning. Tested locally by booting the kernel and writing to and reading from a BtrFS filesystem with zstd compression enabled. I was unable to reproduce the issue before the fix, however it is a trivial change. Link: https://lkml.kernel.org/r/20231012213428.1390905-1-nickrterrell@gmail.com Reported-by: syzbot+1f2eb3e8cd123ffce499@syzkaller.appspotmail.com Reported-by: Eric Biggers <ebiggers@kernel.org> Reported-by: Kees Cook <keescook@chromium.org> Signed-off-by: Nick Terrell <terrelln@fb.com> Reviewed-by: Kees Cook <keescook@chromium.org>
1 parent ffc2532 commit 77618db

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/zstd/common/fse_decompress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size
312312

313313
typedef struct {
314314
short ncount[FSE_MAX_SYMBOL_VALUE + 1];
315-
FSE_DTable dtable[1]; /* Dynamically sized */
315+
FSE_DTable dtable[]; /* Dynamically sized */
316316
} FSE_DecompressWksp;
317317

318318

0 commit comments

Comments
 (0)