]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/systemctl/fuzz-systemctl-parse-argv.c
tree-wide: use -EBADF for fd initialization
[thirdparty/systemd.git] / src / systemctl / fuzz-systemctl-parse-argv.c
index 588c8b56c5cebc518e0e45a229e94452d92a694d..a97db68d2dc4ce0e54f4c4cbbe585fd20d9d144e 100644 (file)
@@ -6,6 +6,7 @@
 #include "env-util.h"
 #include "fd-util.h"
 #include "fuzz.h"
+#include "nulstr-util.h"
 #include "selinux-util.h"
 #include "static-destruct.h"
 #include "stdio-util.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         _cleanup_strv_free_ char **argv = NULL;
-        _cleanup_close_ int orig_stdout_fd = -1;
+        _cleanup_close_ int orig_stdout_fd = -EBADF;
         int r;
 
+        if (size > 16*1024)
+                return 0; /* See the comment below about the limit for strv_length(). */
+
         /* We don't want to fill the logs with messages about parse errors.
          * Disable most logging if not running standalone */
         if (!getenv("SYSTEMD_LOG_LEVEL"))