summaryrefslogtreecommitdiff
path: root/inffast.c
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2021-06-09 19:15:52 +0300
committerHans Kristian Rosbach <hk-github@circlestorm.org>2021-06-11 19:53:08 +0200
commit91599b37e533359a1027d1b6b2be8ed2745145f1 (patch)
tree2431074067d0e270e98126c221537a2a90f621d0 /inffast.c
parentce4409c1241a60c7ba5807530adf4a795ff87afe (diff)
[inflate_fast] Always use safe versions of chunkcopy and chunkmemset to avoid errors with optimizations enabled.
Diffstat (limited to 'inffast.c')
-rw-r--r--inffast.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/inffast.c b/inffast.c
index 18ce570..c8d3da3 100644
--- a/inffast.c
+++ b/inffast.c
@@ -260,15 +260,11 @@ void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) {
out = functable.chunkcopy_safe(out, from, len, safe);
}
} 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,
- so unroll and roundoff operations can write beyond `out+len` so long
- as they stay within 258 bytes of `out`.
- */
+ /* Whole reference is in range of current output. */
if (dist >= len || dist >= state->chunksize)
- out = functable.chunkcopy(out, out - dist, len);
+ out = functable.chunkcopy_safe(out, out - dist, len, safe);
else
- out = functable.chunkmemset(out, dist, len);
+ out = functable.chunkmemset_safe(out, dist, len, safe - out + 1);
}
} else if ((op & 64) == 0) { /* 2nd level distance code */
here = dcode + here->val + BITS(op);