Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed two issues found with fuzzing. #52

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ static uint32_t longest_match(deflate_state *s, IPos cur_match /* current match
register uint8_t *scan = s->window + s->strstart; /* current string */
register uint8_t *match; /* matched string */
register int len; /* length of current match */
int best_len = s->prev_length; /* best match length so far */
int best_len = (s->prev_length == 0) ? ACTUAL_MIN_MATCH-1 : s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
s->strstart - (IPos)MAX_DIST(s) : NIL;
Expand Down Expand Up @@ -1467,8 +1467,8 @@ static block_state deflate_stored(deflate_state *s, int flush)
uint64_t max_block_size = 0xffff;
uint64_t max_start;

if (max_block_size > s->pending_buf_size - 5) {
max_block_size = s->pending_buf_size - 5;
if (max_block_size > s->pending_buf_size - 6) {
max_block_size = s->pending_buf_size - 6;
}

/* Copy as much as possible from input to output: */
Expand Down Expand Up @@ -1688,7 +1688,7 @@ static block_state deflate_slow(deflate_state *s, int flush) {
insert_cnt = max_insert - s->strstart;

bulk_insert_str(s, s->strstart + 1, insert_cnt);
s->prev_length = 0;
s->prev_length = ACTUAL_MIN_MATCH-1;
s->match_available = 0;
s->match_length = ACTUAL_MIN_MATCH-1;
s->strstart += mov_fwd + 1;
Expand Down