]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz-systemctl-parse-argv: avoid "leak" of bus object
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 07:48:37 +0000 (08:48 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 07:57:12 +0000 (08:57 +0100)
Memory sanitizer would report leaked memory from --boot-load-entry=help.

Maybe we should disable all bus connections from the fuzzer? It seems not
appropriate to communicate with logind. OTOH, in a real fuzzing environment
this call should just fail, so maybe that's OK.

src/systemctl/fuzz-systemctl-parse-argv.c

index f884917e17fff42504030d957c3fa5aee0c3c522..cf66fa4bb7b14e721fe3b4c86a8f0aa91a94e1b4 100644 (file)
@@ -9,6 +9,7 @@
 #include "stdio-util.h"
 #include "strv.h"
 #include "systemctl.h"
+#include "systemctl-util.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         _cleanup_strv_free_ char **argv = NULL;
@@ -54,5 +55,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
                 assert_se(freopen(path, "w", stdout));
         }
 
+        release_busses(); /* We open the bus for communication with logind.
+                           * It needs to be closed to avoid apparent leaks. */
         return 0;
 }