Skip to content

Commit

Permalink
Compute the "safe" distance properly
Browse files Browse the repository at this point in the history
The safe pointer that is computed is an exclusive, not inclusive bounds.
While we were probably rarely ever bit this, if ever, it still makes
sense to apply the limit, properly.
  • Loading branch information
KungFuJesus authored and Dead2 committed Oct 8, 2024
1 parent 8d10c30 commit 3297953
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inffast_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start) {
if (dist >= len || dist >= state->chunksize)
out = chunkcopy_safe(out, out - dist, len, safe);
else
out = CHUNKMEMSET_SAFE(out, dist, len, (unsigned)((safe - out) + 1));
out = CHUNKMEMSET_SAFE(out, dist, len, (unsigned)((safe - out)));
} else {
/* Whole reference is in range of current output. No range checks are
necessary because we start with room for at least 258 bytes of output,
Expand Down

0 comments on commit 3297953

Please sign in to comment.