]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lzxpress: compress shortcut if we've reached maximum length
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sun, 15 May 2022 00:28:32 +0000 (12:28 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 17 May 2022 23:11:21 +0000 (23:11 +0000)
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

lib/compression/lzxpress.c
selftest/knownfail.d/lzxpress

index 71b39c1efb379b5aa94508eeea3ebd320fd19844..6b2aeef02f6c918e0a446f602c58b62cac247b62 100644 (file)
@@ -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;
+                               }
                        }
                }
 
index 0c3a6d38c7f78588c598c45dc27c6819add6b86b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-samba4.local.compression.lzxpress_many_zeros
\ No newline at end of file