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

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

Issue 2346723002: Add fuzzer for PRTime() from NSPR. (Closed)
Patch Set: Revert PS #2. 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 | « testing/libfuzzer/fuzzers/dicts/prtime.dict ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/fuzzers/prtime_fuzzer.cc
diff --git a/testing/libfuzzer/fuzzers/prtime_fuzzer.cc b/testing/libfuzzer/fuzzers/prtime_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8aef215902fcd546d15c254228a8949d8d44c95
--- /dev/null
+++ b/testing/libfuzzer/fuzzers/prtime_fuzzer.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <string>
+
+#include "base/third_party/nspr/prtime.h"
+
+PRTime parsed_time;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ if (size < 1)
+ return 0;
+
+ const uint8_t selector = data[0];
+
+ // Using std::string instead of a (potentially faster) fixed buffer to catch
+ // accesses beyond the end of the string.
+ std::string str(reinterpret_cast<const char*>(data+1), size - 1);
+ PR_ParseTimeString(str.c_str(), selector & 1, &parsed_time);
+
+ return 0;
+}
« no previous file with comments | « testing/libfuzzer/fuzzers/dicts/prtime.dict ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698