Commit 22d7c9d0 authored by mmoroz's avatar mmoroz Committed by Commit bot

[libfuzzer] Add fuzzer for third_party/hunspell with dictionary.

Ported from google3 with minor changes.

R=aizatsky@chromium.org, kcc@chromium.org, ochang@chromium.org, rouslan@chromium.org, phajdan.jr@chromium.org

BUG=539572

Review-Url: https://codereview.chromium.org/2012443002
Cr-Commit-Position: refs/heads/master@{#398274}
parent ea056bf4
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//testing/libfuzzer/fuzzer_test.gni")
config("hunspell_config") {
defines = [
"HUNSPELL_STATIC",
......@@ -109,3 +111,16 @@ source_set("hunspell") {
]
}
}
fuzzer_test("hunspell_fuzzer") {
sources = [
"fuzz/hunspell_fuzzer.cc",
"fuzz/hunspell_fuzzer_dictionary.h",
]
deps = [
":hunspell",
]
# This is a dictionary for the fuzzer, not a spellcheck dictionary.
dict = "fuzz/hunspell.dict"
}
This source diff could not be displayed because it is too large. You can view the blob instead.
// 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 "third_party/hunspell/src/hunspell/hunspell.hxx"
#include "third_party/hunspell/fuzz/hunspell_fuzzer_dictionary.h"
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (!size)
return 0;
static Hunspell* hunspell = new Hunspell(
reinterpret_cast<const unsigned char*>(kHunspellDictionary),
sizeof(kHunspellDictionary));
std::string data_string(reinterpret_cast<const char*>(data), size);
hunspell->spell(data_string.c_str());
char** suggestions = nullptr;
int suggetion_length = hunspell->suggest(&suggestions, data_string.c_str());
hunspell->free_list(&suggestions, suggetion_length);
return 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -83,6 +83,7 @@ WHITELISTED_LICENSES = [
'MPL (v1.1) BSD (3 clause) LGPL (v2.1 or later)',
'MPL (v1.1) BSD-like GPL (unversioned/unknown version)',
'MPL (v1.1) BSD-like GPL (v2) LGPL (v2.1 or later)',
'MPL (v1.1) BSD-like LGPL (v2.1 or later)',
'MPL (v1.1) BSD-like',
'MPL (v1.1) GPL (unversioned/unknown version)',
'MPL (v1.1) GPL (v2) LGPL (v2 or later)',
......
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