diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-06-01 12:48:17 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-06-01 12:48:17 +0300 |
commit | 369f72fd656f537a9a8e06f13e6d0d4c242be22f (patch) | |
tree | 7b0d983e6be1ebb4d1361b2efcd125eeacad97a0 /src/liblzma/lzma/lzma_encoder_getoptimumfast.c | |
parent | Typo fixes from meyering. (diff) | |
download | xz-369f72fd656f537a9a8e06f13e6d0d4c242be22f.tar.xz |
Fix a buffer overflow in the LZMA encoder. It was due to my
misunderstanding of the code. There's no tiny fix for this
problem, so I also cleaned up the code in general.
This reduces the speed of the encoder 2-5 % in the fastest
compression mode ("lzma -1"). High compression modes should
have no noticeable performance difference.
This commit breaks things (especially LZMA_SYNC_FLUSH) but I
will fix them once the new format and LZMA2 has been roughly
implemented. Plain LZMA won't support LZMA_SYNC_FLUSH at all
and won't be supported in the new .lzma format. This may
change still but this is what it looks like now.
Support for known uncompressed size (that is, LZMA or LZMA2
without EOPM) is likely to go away. This means there will
be API changes.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/lzma/lzma_encoder_getoptimumfast.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/liblzma/lzma/lzma_encoder_getoptimumfast.c b/src/liblzma/lzma/lzma_encoder_getoptimumfast.c index e6cee19d..fa06be21 100644 --- a/src/liblzma/lzma/lzma_encoder_getoptimumfast.c +++ b/src/liblzma/lzma/lzma_encoder_getoptimumfast.c @@ -65,7 +65,7 @@ lzma_get_optimum_fast(lzma_coder *restrict coder, uint32_t rep_max_index = 0; for (uint32_t i = 0; i < REP_DISTANCES; ++i) { - const uint32_t back_offset = coder->rep_distances[i] + 1; + const uint32_t back_offset = coder->reps[i] + 1; // If the first two bytes (2 == MATCH_MIN_LEN) do not match, // this rep_distance[i] is not useful. This is indicated @@ -168,7 +168,7 @@ lzma_get_optimum_fast(lzma_coder *restrict coder, --num_available_bytes; for (uint32_t i = 0; i < REP_DISTANCES; ++i) { - const uint32_t back_offset = coder->rep_distances[i] + 1; + const uint32_t back_offset = coder->reps[i] + 1; if (buf[1] != *(buf + 1 - back_offset) || buf[2] != *(buf + 2 - back_offset)) { |