summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Semjonovs <asemjonovs@google.com>2022-10-18 10:59:30 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-20 23:02:32 +0000
commitba83e48f20a8f9cc4ffaabbff3e69fb33dbe1141 (patch)
tree916f9b2840eab267236cab475e20d50a770f8d99
parenta64566ebbad3160c36b8c991e476e2dd2c4c5917 (diff)
downloadchrome-ec-ba83e48f20a8f9cc4ffaabbff3e69fb33dbe1141.tar.gz
util: panic info fuzzer
Add fuzzer for parse_panic_info BUG=None BRANCH=NONE TEST=./ec_panicinfo_fuzzer -runs=5000 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Change-Id: Iab9ed0cd0d639ebf17db95c7f060512adcc69fb2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3964545 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com>
-rw-r--r--util/ec_panicinfo_fuzzer.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/util/ec_panicinfo_fuzzer.cc b/util/ec_panicinfo_fuzzer.cc
new file mode 100644
index 0000000000..95f1871837
--- /dev/null
+++ b/util/ec_panicinfo_fuzzer.cc
@@ -0,0 +1,22 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_panicinfo.h"
+
+/* Fuzzing Build command:
+ * $ clang++ ec_panicinfo_fuzzer.cc ec_panicinfo.cc -g -fsanitize=address,fuzzer
+ * -o ec_panicinfo_fuzzer
+ * -I../include/ -I../chip/host/ -I../board/host/ -I../fuzz -I../test
+ *
+ * Run Fuzzing:
+ * $ ./ec_panicinfo_fuzzer -runs=5000
+ */
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, unsigned int size)
+{
+ parse_panic_info((const char *)data, size);
+
+ return 0;
+}