Parcourir la source

Meta: Add a `Shell --posix` parser fuzzer

Ali Mohammad Pur il y a 2 ans
Parent
commit
617d112780
2 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. 1 0
      Meta/Lagom/Fuzzers/CMakeLists.txt
  2. 19 0
      Meta/Lagom/Fuzzers/FuzzShellPosix.cpp

+ 1 - 0
Meta/Lagom/Fuzzers/CMakeLists.txt

@@ -62,6 +62,7 @@ add_simple_fuzzer(FuzzSHA256 LibCrypto)
 add_simple_fuzzer(FuzzSHA384 LibCrypto)
 add_simple_fuzzer(FuzzSHA512 LibCrypto)
 add_simple_fuzzer(FuzzShell LibShell)
+add_simple_fuzzer(FuzzShellPosix LibShell)
 add_simple_fuzzer(FuzzSQLParser LibSQL)
 add_simple_fuzzer(FuzzTar LibArchive)
 add_simple_fuzzer(FuzzTTF LibGfx)

+ 19 - 0
Meta/Lagom/Fuzzers/FuzzShellPosix.cpp

@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2020-2023, the SerenityOS developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/StringView.h>
+#include <Shell/PosixParser.h>
+#include <Shell/Shell.h>
+#include <stddef.h>
+#include <stdint.h>
+
+extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
+{
+    auto source = StringView(static_cast<unsigned char const*>(data), size);
+    Shell::Posix::Parser parser(source);
+    (void)parser.parse();
+    return 0;
+}