From 425ac7a253321b8e8d1b0a0f7a173892a3abc385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 16 Feb 2021 14:27:26 +0100 Subject: [PATCH] fuzz-systemctl-parse-argv: call static destuctors 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 | 9 +++++++++ .../missing-strv-free.input | Bin 0 -> 99 bytes 2 files changed, 9 insertions(+) create mode 100644 test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input diff --git a/src/systemctl/fuzz-systemctl-parse-argv.c b/src/systemctl/fuzz-systemctl-parse-argv.c index cf66fa4bb7..31269863c1 100644 --- a/src/systemctl/fuzz-systemctl-parse-argv.c +++ b/src/systemctl/fuzz-systemctl-parse-argv.c @@ -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 index 0000000000000000000000000000000000000000..5600f4fd0080a6f7e6d98834b7a58775f1c57888 GIT binary patch literal 99 zcma*bK?;B{3ona|-(pFvDhrrDm`> O6=E*|Yt6nCf}+1zNgCJy literal 0 HcmV?d00001