]> Git Repo - linux.git/commitdiff
zstd: Fix array-index-out-of-bounds UBSAN warning
authorNick Terrell <[email protected]>
Thu, 12 Oct 2023 19:55:34 +0000 (12:55 -0700)
committerNick Terrell <[email protected]>
Wed, 15 Nov 2023 01:12:52 +0000 (17:12 -0800)
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/[email protected]
Reported-by: [email protected]
Reported-by: Eric Biggers <[email protected]>
Reported-by: Kees Cook <[email protected]>
Signed-off-by: Nick Terrell <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
lib/zstd/common/fse_decompress.c

index a0d06095be83de601e292f3154235bfcde946dae..8dcb8ca39767c8dfbf63eaf5e82ce46c4b848381 100644 (file)
@@ -312,7 +312,7 @@ size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size
 
 typedef struct {
     short ncount[FSE_MAX_SYMBOL_VALUE + 1];
-    FSE_DTable dtable[1]; /* Dynamically sized */
+    FSE_DTable dtable[]; /* Dynamically sized */
 } FSE_DecompressWksp;
 
 
This page took 0.054189 seconds and 4 git commands to generate.