summaryrefslogtreecommitdiff
path: root/lib/compression
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-05-15 12:28:32 +1200
committerDouglas Bagnall <dbagnall@samba.org>2022-05-17 23:11:21 +0000
commit637e7cbdbab6a5229b51954f506e51c677739ce8 (patch)
tree0426ddfcb7dcd19195bf693f156a1c093f549a4c /lib/compression
parent04309bc68240f55028c7d5108c55625199ad8884 (diff)
downloadsamba-637e7cbdbab6a5229b51954f506e51c677739ce8.tar.gz
lzxpress: compress shortcut if we've reached maximum length
A simple degenerate case for our compressor has been a large number of repeated bytes that will match the maximum length (~64k) at all 8192 search positions, 8191 of which searches are in vain because the matches are not of greater length than the first one. Here we recognise the inevitable and reduce runtime proportionately. Credit to OSS-Fuzz. REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47428 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Tue May 17 23:11:21 UTC 2022 on sn-devel-184
Diffstat (limited to 'lib/compression')
-rw-r--r--lib/compression/lzxpress.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/compression/lzxpress.c b/lib/compression/lzxpress.c
index 71b39c1efb3..6b2aeef02f6 100644
--- a/lib/compression/lzxpress.c
+++ b/lib/compression/lzxpress.c
@@ -118,6 +118,10 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
found = true;
best_len = len;
best_offset = offset;
+ if (best_len == max_len) {
+ /* We're not going to do better than this */
+ break;
+ }
}
}