Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: testing/libfuzzer/fuzzers/base_json_reader_fuzzer.cc

Issue 2348053002: Include JSONParser options into its fuzzer. (Closed)
Patch Set: Move stack variables to the heap. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/fuzzers/base_json_reader_fuzzer.cc
diff --git a/testing/libfuzzer/fuzzers/base_json_reader_fuzzer.cc b/testing/libfuzzer/fuzzers/base_json_reader_fuzzer.cc
index fd9d2835dd225c738781256f29306aa5be63246e..7b3e44891b7690816be4bc972f34ac56a2701732 100644
--- a/testing/libfuzzer/fuzzers/base_json_reader_fuzzer.cc
+++ b/testing/libfuzzer/fuzzers/base_json_reader_fuzzer.cc
@@ -10,9 +10,18 @@
#include "base/json/json_reader.h"
#include "base/values.h"
+int error_code, error_line, error_column;
+std::string error_message;
+
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- base::JSONReader reader;
- reader.Read(std::string(reinterpret_cast<const char*>(data), size));
+ if (size < 1)
+ return 0;
+
+ const std::string input_string(reinterpret_cast<const char*>(data), size - 1);
+ const int options = data[size - 1];
+ base::JSONReader::ReadAndReturnError(input_string, options, &error_code,
+ &error_message, &error_line,
+ &error_column);
return 0;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698