Commit 1ec4f481 authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

Add a fuzzer for DateTimeFormat::Parse

Change-Id: I9f45508bb229a809e15423c5d9f48271702719af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866558
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707372}
parent f7c46eec
# Copyright 2019 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.
# Fields
"G"
"y"
"u"
"Q"
"q"
"M"
"L"
"w"
"W"
"d"
"D"
"F"
"g"
"E"
"e"
"c"
"a"
"h"
"H"
"K"
"k"
"m"
"s"
"S"
"A"
"z"
"Z"
"v"
# Quote
"'"
# Separators
"."
":"
","
"\""
...@@ -2117,6 +2117,19 @@ fuzzer_test("blink_png_decoder_fuzzer") { ...@@ -2117,6 +2117,19 @@ fuzzer_test("blink_png_decoder_fuzzer") {
] ]
} }
# Fuzzer for blink::DateTimeFormat.
fuzzer_test("blink_date_time_format_fuzzer") {
sources = [
"text/date_time_format_fuzzer.cc",
]
deps = [
":blink_fuzzer_test_support",
":platform",
]
dict = "//testing/libfuzzer/fuzzers/dicts/date.dict"
seed_corpus = "text/date_time_format_fuzzer_seed_corpus"
}
# Fuzzer for blink::JSONParser. # Fuzzer for blink::JSONParser.
fuzzer_test("blink_json_parser_fuzzer") { fuzzer_test("blink_json_parser_fuzzer") {
sources = [ sources = [
......
// Copyright 2019 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 "third_party/blink/renderer/platform/text/date_time_format.h"
#include <stddef.h>
#include <stdint.h>
#include "third_party/blink/renderer/platform/testing/blink_fuzzer_test_support.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class DummyTokenHandler : public DateTimeFormat::TokenHandler {
public:
~DummyTokenHandler() override = default;
void VisitField(DateTimeFormat::FieldType field_type, int count) override {
CHECK(field_type != DateTimeFormat::FieldType::kFieldTypeInvalid);
CHECK_GE(count, 1);
}
void VisitLiteral(const WTF::String& string) override {
CHECK_GT(string.length(), 0u);
}
};
} // namespace blink
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
static blink::BlinkFuzzerTestSupport test_support =
blink::BlinkFuzzerTestSupport();
blink::DummyTokenHandler handler;
blink::DateTimeFormat::Parse(
WTF::String::FromUTF8(reinterpret_cast<const char*>(data), size),
handler);
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