Commit 0531c60c authored by tnagel's avatar tnagel Committed by Commit bot

Add fuzzer for PRTime() from NSPR.

BUG=none

Review-Url: https://codereview.chromium.org/2346723002
Cr-Commit-Position: refs/heads/master@{#419255}
parent 30ddc6c6
...@@ -400,3 +400,14 @@ fuzzer_test("skia_pathop_fuzzer") { ...@@ -400,3 +400,14 @@ fuzzer_test("skia_pathop_fuzzer") {
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ] additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
} }
} }
fuzzer_test("prtime_fuzzer") {
sources = [
"prtime_fuzzer.cc",
]
deps = [
"//base",
]
dict = "dicts/prtime.dict"
libfuzzer_options = [ "max_len=1024" ]
}
"0"
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"
" "
# <tab>
"\x09"
":"
"."
"/"
"-"
"+"
";"
"("
")"
"["
"]"
"T"
"Z"
"AM"
"PM"
"Mon"
"Tue"
"Wed"
"Thu"
"Fri"
"Sat"
"Sun"
"Jan"
"Feb"
"Mar"
"Apr"
"May"
"Jun"
"Jul"
"Aug"
"Sep"
"Oct"
"Nov"
"Dec"
"AST"
"BST"
"CDT"
"CST"
"EDT"
"EET"
"EST"
"GMT"
"JST"
"MDT"
"MET"
"MST"
"NST"
"PDT"
"PST"
"GMT"
// 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment