Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e1c0784

Browse files
committedNov 28, 2023
lib/decompress: check for reserved bit corruption in zstd
The patch adds a validation to ensure that the last field, which is reserved, must be all-zeroes in ZSTD_decodeSeqHeaders. This prevents potential corruption from going undetected. Fixes an issue where corrupted input could lead to undefined behavior due to improper validation of reserved bits. Signed-off-by: aimuz <mr.imuz@gmail.com>
1 parent ce34dc3 commit e1c0784

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎lib/decompress/zstd_decompress_block.c

+1
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
607607

608608
/* FSE table descriptors */
609609
RETURN_ERROR_IF(ip+1 > iend, srcSize_wrong, ""); /* minimum possible size: 1 byte for symbol encoding types */
610+
RETURN_ERROR_IF(*ip & 3, corruption_detected, ""); /* The last field, Reserved, must be all-zeroes. */
610611
{ symbolEncodingType_e const LLtype = (symbolEncodingType_e)(*ip >> 6);
611612
symbolEncodingType_e const OFtype = (symbolEncodingType_e)((*ip >> 4) & 3);
612613
symbolEncodingType_e const MLtype = (symbolEncodingType_e)((*ip >> 2) & 3);

0 commit comments

Comments
 (0)
Please sign in to comment.