[zlib] Fix minigzip_fuzzer: compression level never varies from default#15099
Open
OwenSanzas wants to merge 1 commit intogoogle:masterfrom
Open
[zlib] Fix minigzip_fuzzer: compression level never varies from default#15099OwenSanzas wants to merge 1 commit intogoogle:masterfrom
OwenSanzas wants to merge 1 commit intogoogle:masterfrom
Conversation
… leaks
The compression level is encoded as a raw integer (0x00-0x09) instead
of an ASCII digit ('0'-'9'), so gzopen() always falls back to the
default compression level 6. Levels 0-5 and 7-9 are never tested.
Fix: outmode[2] = '0' + data[0] % 10;
Also fix two resource leaks:
- file_compress(): close FILE *in when gzopen() fails
- file_uncompress(): close gzFile in when fopen() fails
Coverage improvement (ASan, 60s runs):
- INITED edges: 815 -> 866 (+6.3%)
- Final edges: 870 -> 968 (+11.3%)
|
OwenSanzas is a new contributor to projects/zlib. The PR must be approved by known contributors before it can be merged. The past contributors are: hunsche, evverx, serge-sans-paille, vitaliset, fanquake, conNULL, hkctkuy, jvoisin, inferno-chromium, cvediver, Dor1s, gcp1304 (unverified), ProgramMax (unverified), sebpop (unverified) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
minigzip_fuzzer.cencodes the compression level as a raw integer (0x00–0x09) instead of an ASCII digit ('0'–'9'). Sincegzopen()parses the mode string looking for characters in the range'0'–'9'(0x30–0x39), control characters 0x00–0x09 never match, and the compression level always falls back toZ_DEFAULT_COMPRESSION(level 6). The fuzzer's intent to test all 10 compression levels is completely defeated.Bug (line 468):
Fix:
In zlib's
gz_open(), the level is parsed as:Since 0x00–0x09 don't satisfy
>= '0'(0x30), the loop never matches.Also fixes two resource leaks on error paths:
file_compress():FILE *inleaked whengzopen()failsfile_uncompress():gzFile inleaked whenfopen()failsEvidence
Coverage comparison (ASan, 60-second runs from seed corpus):
The fixed version reaches 51 more edges just from replaying the same seed corpus, because different compression levels exercise different code paths in zlib's deflate implementation.