]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
oss-fuzz: reject giant configs early 3760/head
authorEvgeny Vereshchagin <evvers@ya.ru>
Tue, 30 Mar 2021 07:26:39 +0000 (07:26 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Tue, 30 Mar 2021 07:26:39 +0000 (07:26 +0000)
It should help the fuzzer to avoid running into timeouts
like https://oss-fuzz.com/testcase-detail/5132999948632064.
Hopefully, once this is merged OSS-Fuzz will report only
infinite loops as timeouts.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
src/tests/fuzz-lxc-config-read.c

index bc70dcf0399a4d110f16ac3cf7dea728eb8cbafc..ab5aa601c0fb8c8e7792b9a847a22715b39d0ecc 100644 (file)
@@ -13,6 +13,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
        char tmpf[] = "/tmp/fuzz-lxc-config-read-XXXXXX";
        struct lxc_conf *conf = NULL;
 
+       /*
+        * 100Kb should probably be enough to trigger all the issues
+        * we're interested in without any timeouts
+        */
+       if (size > 102400)
+               return 0;
+
        fd = lxc_make_tmpfile(tmpf, false);
        lxc_test_assert_abort(fd >= 0);
        lxc_write_nointr(fd, data, size);