1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00
Commit Graph

47 Commits

Author SHA1 Message Date
Yann Collet
babf4f5886 ossfuzz: occasionally skip checksums
decompress_frame_fuzzer, round_trip_frame_fuzzer and compress_frame_stream_fuzzer
now enable the skipChecksums decompression option for about 1 input in 8.
2026-10-14 15:45:29 -07:00
Yann Collet
9bf77b2439 Merge pull request #1842 from lz4/fuzz_dictstream_check
ossfuzz: check dictStream allocations in the stream fuzzer
2026-10-12 23:15:14 -07:00
Yann Collet
b2806bb72b ossfuzz: check dictStream allocations in the stream fuzzer
state_attachDictRoundTrip() and state_attachDictHCRoundTrip() used the result
of LZ4_createStream() / LZ4_createStreamHC() without checking it.
On allocation failure, the NULL stream was dereferenced inside lz4.c / lz4hc.c,
showing up as a library crash instead of a failed assert in the harness.

Same issue as #1813, in the dictionary paths.
2026-10-12 22:16:27 -07:00
Mohil Ahuja
73ee988e95 ossfuzz: check cstreamHC after LZ4_createStreamHC() in the stream fuzzer
state_create() asserted state.cstream a second time instead of the
new state.cstreamHC, so a failed LZ4_createStreamHC() went unnoticed and
state_reset() then passed NULL to LZ4_resetStreamHC_fast().

Fixes #1813
2026-10-10 15:41:58 +05:30
Yann Collet
ba56b8c14e ossfuzz: FUZZ_dataProducer_retrieve32() returns 32 bits
It consumed 4 bytes, but only returned the first one (`*(data + size - 4)` is a byte),
since 8edc5879 (2019).
As a consequence, all values derived from it were limited to 0-255 :
most capacities, offsets and dictionary sizes chosen by the fuzzers
only covered a small fraction of their intended range.

It now returns the 4 bytes, combined in little-endian order.
The low byte is unchanged and the number of consumed bytes is the same,
so values within power-of-2 ranges <= 256 (such as boolean flags) are unaffected,
limiting the impact on existing corpora.

Also : FUZZ_dataProducer_range32() stores the seed as uint32_t (was size_t).
2026-10-08 12:58:40 -07:00
Yann Collet
07eea33feb ossfuzz: unit test for the fuzz data producer
`make -C ossfuzz test` checks that FUZZ_dataProducer_retrieve32()
reads 32-bit values from the end of input,
and that FUZZ_dataProducer_range32() can produce any value of its range.

This test fails on current dev :
FUZZ_dataProducer_retrieve32() only returns a single byte,
so range32() never produces values > 255.
2026-10-08 12:57:07 -07:00
Yann Collet
c8d0a16537 tests: LZ4F compression into dst capacities < compressBound (#1817)
Bounds should guarantee success, without being requirements :
compression must succeed if and only if its output fits,
and then produce the same output as with a bound-sized buffer.

frametest unit tests :
- LZ4F_compressBegin*() into exactly the header size (7-19 bytes),
  and a failed begin doesn't disturb a frame in progress
- LZ4F_compressFrame() and LZ4F_compressFrame_usingCDict() :
  exact frame size succeeds with identical output, any smaller capacity fails
  (every capacity for small frames, element boundaries otherwise)
- streaming : random scripts of updates, uncompressed updates and flushes;
  each operation into exactly its output size, failures just before element boundaries,
  frame invalidated after a failure, context reusable for a new frame
- LZ4F_flush() and LZ4F_compressEnd() require a frame in progress
- mixed updates : rewrite the insufficient capacity test
frametest fuzzer : random undersized capacities for compressFrame, updates, flushes and compressEnd

ossfuzz :
- compress_frame_fuzzer : success if and only if the frame fits, identical output
- new compress_frame_stream_fuzzer : streaming with random capacities,
  in lockstep with a reference context receiving bound-sized buffers
- round_trip_frame_uncompressed_fuzzer : pass remaining capacity

Note : byte-exact comparisons start from fresh contexts,
because output of linked blocks at fast levels depends on context history
(pre-existing behavior, unrelated to capacity).

These tests fail on current dev.
2026-10-08 09:45:58 -07:00
Yann Collet
d22ca27e8d add ossfuzz fuzzer binaries to .gitignore 2026-06-01 14:34:25 -07:00
Dimitri Papadopoulos
b7ec6e3f09 Macros should not use a trailing semicolon 2023-06-25 17:43:56 +02:00
Dimitri Papadopoulos
b1fd838cdb Fix typo found by codespell 2023-01-08 09:44:22 +01:00
Yann Collet
34f25c3c1d fixed direct-leak in round_trip_fuzzer.c
reported by oss-fuzz
2022-07-10 15:32:42 -07:00
Yonatan Komornik
910ec80d28 - Fixed incorrect free in round_trip_fuzzer.c (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48884)
- Fixed `round_trip_frame_uncompressed_fuzzer.c` to not use uninitialized memory (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48910)
2022-07-09 14:08:06 -07:00
Yann Collet
d3d3fad70c ignore ossfuzz artifact 2022-07-05 15:39:15 -07:00
Yann Collet
4da5c4dd30 Merge pull request #1094 from alexmohr/add-uncompressed-api
frame-api: add function to insert uncomressed data
2022-07-05 15:07:36 -07:00
Alexander Mohr
0ac3c74de1 review: fix findings
* replace assert with test for LZ4F_uncompressedUpdate
* update documentation to incldue correct docstring
* remove unecessary entry point
* remove compress_linked_block_mode from fuzzing test

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
2022-07-05 21:14:34 +02:00
Yann Collet
f745a01cfd clarify yet another time what dual-license means 2022-07-04 16:36:19 -07:00
Yann Collet
c63801d03d ignore ossfuzz artifacts 2022-07-01 10:36:22 -07:00
Alexander Mohr
5065080664 ossfuzz: extend fuzzing test to include linked blocks
fuzzing test now tests linked and independent blocks

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
2022-06-13 07:46:53 +02:00
Alexander Mohr
1738b50443 fuzz-test: add fuzz test for uncompressed api
add a fuzzing test for uncompressed frame api

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
2022-06-11 22:47:44 +02:00
Alexander Mohr
5c7382798e review: Fix review findings
This commit fixes the review findings

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
2022-06-10 06:37:57 +00:00
Qi Wang
582f5fe534 ossfuzz: add fuzz for LZ4_decompress_safe_partial_usingDict
Signed-off-by: Qi Wang <wangqi@linux.alibaba.com>
2022-06-07 17:13:01 +08:00
Dimitri Papadopoulos
4bdfb08b95 Fix typos found by codespell 2021-11-25 15:32:37 +01:00
Nick Terrell
073fe18edf [ossfuzz] Fix parallel builds
With `make -j` multiple builds of `standaloneengine.o` happened in
parallel. Fix this by detecting `standaloneengine.o` and moving it to a
depedency.
2020-11-05 10:31:07 -08:00
Yann Collet
392809d66e fix minor static analyzer warnings
detected by scan-build and cppcheck
fix #786
2020-09-29 17:09:58 -07:00
Nick Terrell
f803995b77 [CI][ossfuzz] Fix string equal 2020-08-24 11:23:04 -07:00
Nick Terrell
e97ff29627 [CI][Fuzz] Fix Travis-CI fuzzer tests
Fixes #781
2020-08-19 18:48:10 -07:00
Yann Collet
3dd34df751 added target lz4-wlib
variant of lz4 linking to liblz4 dynamic library

requires the dynamic library to expose static-only symbols (experimental API)

Example for #888
2020-08-11 14:07:51 -07:00
Bimba Shrestha
192161e97e Using size instead of LZ4_compressBound(size) <- causes heap overflow 2019-09-23 11:54:56 -07:00
Bimba Shrestha
8edc5879d0 Retreiving 32 bits from the end for fuzzer 2019-09-13 18:08:58 -07:00
Bimba Shrestha
9cb73d69c4 Addressing naming nits and moving size modification up in all fuzzers 2019-09-13 16:04:48 -07:00
Bimba Shrestha
208694297a Seperating the seed generation and use 2019-09-13 14:07:52 -07:00
Bimba Shrestha
7d153a704d Making fuzzers use dataProducer api instead of random seed for decisions 2019-08-30 10:27:42 -07:00
bimbashrestha
dc17d39c2f Adding comments, fixing nit, and hiding the struct in data producer api 2019-08-16 17:14:47 -07:00
bimbashrestha
f839e9fe8a Seperating fuzz data producer api impl and header, using data producer on the easy fuzzers 2019-08-16 16:43:28 -07:00
bimbashrestha
a9ac056456 Created a data producer API and used in decompress_fuzzer 2019-08-16 14:19:06 -07:00
bimbashrestha
fad8c97532 Adding fuzz data producer for uint32 and using in decompress_fuzzer
Summary: Consuming bytes from the end of data instead of from the front to prevent "all-in-one" decisions.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2019-08-16 10:50:46 -07:00
Nick Terrell
d28159c025 [fuzz] Add LZ4 frame fuzzers
* Round trip fuzzer
* Compress fuzzer
* Decompress fuzzer
2019-07-18 18:54:59 -07:00
Nick Terrell
675ef9a9fc [fuzz] Add HC fuzzers for round trip, compress, and streaming 2019-07-18 12:29:15 -07:00
Nick Terrell
399a80d48e [fuzzer] Update scripts for new fuzzers 2019-07-18 12:29:15 -07:00
Nick Terrell
9b258abd93 [fuzz] Add a streaming round trip fuzzer 2019-07-18 12:29:15 -07:00
Nick Terrell
3c40db8d25 [ossfuzz] Improve the fuzzers
* Run more decompression variants
* Round trip the compression fuzzer and do partial decompression as well
* Add a compression fuzzer that compresses into a smaller output buffer
  and test the destSize variant

These fuzzers caught 2 bugs that were fixed in the previous commit.
* Input buffer over-read in partial decompress
* Partial decompress fails if output size is 0
2019-07-15 12:22:04 -07:00
Max Dymond
f3ec519f59 Remove unnecessary call to Makefile.inc 2019-06-30 20:16:03 +01:00
Max Dymond
e2a33f12e1 More markups for style changes 2019-06-29 00:23:06 +01:00
Max Dymond
02b5b3c242 Move to using C rather than C++ for compilation 2019-06-28 23:48:33 +01:00
Max Dymond
60d71dc20c Write a simple decompress target as well 2019-06-28 22:43:04 +01:00
Max Dymond
88a7cfd728 Code review markups:
- Correct use of CPPFLAGS
- Detect allocation failure
- Add a CHECK macro for failure
2019-06-28 20:54:46 +01:00
Max Dymond
a5cf079d4d Add a fuzzing target that compiles in the oss-fuzz environment 2019-06-28 08:30:02 +01:00