This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Commit 33f8f35
default_medium: avoid out-of-bounds read
The `match` pointer can be dereferenced outside the `s->window` buffer, so
add a boundary check to avoid the issue.
The issue was detected with valgrind. For example, running `gzip FILE` with
valgrind on Clear Linux OS for a FILE that reproduces the issue:
==1610872== Thread 3:
==1610872== Invalid read of size 1
==1610872== at 0x49E9A98: fizzle_matches (deflate_medium.c:150)
==1610872== by 0x49E9A98: deflate_medium (deflate_medium.c:281)
==1610872== by 0x49EC1E7: deflate (deflate.c:1015)
==1610872== by 0x1195D8: UnknownInlinedFun (pigz.c:1602)
==1610872== by 0x1195D8: compress_thread (pigz.c:1752)
==1610872== by 0x11AFD1: ignition (yarn.c:253)
==1610872== by 0x49CB50E: start_thread (pthread_create.c:481)
==1610872== by 0x4B43B02: clone (in /usr/lib64/haswell/libc-2.33.so)
==1610872== Address 0x4c6369f is 1 bytes before a block of size 65,552 alloc'd
==1610872== at 0x48447DA: malloc (vg_replace_malloc.c:380)
==1610872== by 0x49EAB4C: deflateInit2_ (deflate.c:319)
==1610872== by 0x11933D: compress_thread (pigz.c:1637)
==1610872== by 0x11AFD1: ignition (yarn.c:253)
==1610872== by 0x49CB50E: start_thread (pthread_create.c:481)
==1610872== by 0x4B43B02: clone (in /usr/lib64/haswell/libc-2.33.so)
The out-of-bounds check for `orig` has been added for completeness.1 parent 1ac4c01 commit 33f8f35
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
167 | 171 | | |
168 | 172 | | |
169 | 173 | | |
| |||
0 commit comments