]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz-systemctl-parse-argv: call static destuctors
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 13:27:26 +0000 (14:27 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 16:15:11 +0000 (17:15 +0100)
With all the preparatory work in previous PRs, we can now call static destructors
repeatedly without issue. We need to do it here so that global variables allocated
during parsing are properly freed.

src/systemctl/fuzz-systemctl-parse-argv.c
test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input [new file with mode: 0644]

index cf66fa4bb7b14e721fe3b4c86a8f0aa91a94e1b4..31269863c1e290bb56f41533c96cded8325fd06e 100644 (file)
@@ -6,6 +6,8 @@
 #include "env-util.h"
 #include "fd-util.h"
 #include "fuzz.h"
+#include "selinux-util.h"
+#include "static-destruct.h"
 #include "stdio-util.h"
 #include "strv.h"
 #include "systemctl.h"
@@ -57,5 +59,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 
         release_busses(); /* We open the bus for communication with logind.
                            * It needs to be closed to avoid apparent leaks. */
+
+        mac_selinux_finish();
+
+        /* Call static destructors to do global state cleanup. We do it here, and not in fuzz-main.c so that
+         * any global state is destoyed between fuzzer runs. */
+        static_destruct();
+
         return 0;
 }
diff --git a/test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input b/test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input
new file mode 100644 (file)
index 0000000..5600f4f
Binary files /dev/null and b/test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input differ