From: Douglas Bagnall Date: Sun, 15 May 2022 00:28:32 +0000 (+1200) Subject: lzxpress: compress shortcut if we've reached maximum length X-Git-Tag: talloc-2.3.4~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=637e7cbdbab6a5229b51954f506e51c677739ce8;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andrew Bartlett Autobuild-User(master): Douglas Bagnall Autobuild-Date(master): Tue May 17 23:11:21 UTC 2022 on sn-devel-184 --- 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; + } } } diff --git a/selftest/knownfail.d/lzxpress b/selftest/knownfail.d/lzxpress index 0c3a6d38c7f..e69de29bb2d 100644 --- a/selftest/knownfail.d/lzxpress +++ b/selftest/knownfail.d/lzxpress @@ -1 +0,0 @@ -samba4.local.compression.lzxpress_many_zeros \ No newline at end of file