diff --git a/programs/fileio.c b/programs/fileio.c index 78a906d533b..80c49aecea0 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -3515,7 +3515,7 @@ FIO_analyzeFrames(fileInfo_t* info, FILE* const srcFile) /* Skippable frame */ else if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) { U32 const frameSize = MEM_readLE32(headerBuffer + 4); - long const seek = (long)(8 + frameSize - numBytesRead); + S64 const seek = (S64)ZSTD_SKIPPABLEHEADERSIZE + frameSize - (S64)numBytesRead; ERROR_IF(LONG_SEEK(srcFile, seek, SEEK_CUR) != 0, info_frame_error, "Error: could not find end of skippable frame"); info->numSkippableFrames++; diff --git a/tests/playTests.sh b/tests/playTests.sh index 44bc82b5610..b08424a8d97 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -1637,6 +1637,11 @@ rm -f $TEST_DATA_FILE rm -f $FULL_COMPRESSED_FILE rm -f $TRUNCATED_COMPRESSED_FILE +println "test : detect skippable frame larger than file " +printf '\120\052\115\030\370\377\377\377payload' > tmp_skippable.zst # skippable magic, Frame_Size 0xFFFFFFF8 +zstd --list tmp_skippable.zst && die "-l must fail on truncated skippable frame" +rm -f tmp_skippable.zst + println "\n===> zstd --list/-l errors when presented with stdin / no files" zstd -l && die "-l must fail on empty list of files" zstd -l - && die "-l does not work on stdin"