Commit 54b58935 authored by Christopher Thompson's avatar Christopher Thompson Committed by Commit Bot

Add IcuEnvironment setup to affiliation parser fuzzer

The lookup_affiliation_response_parser_fuzzer frequently crashes due to
being unable to open the libicu test environment data tables. This adds
IcuEnvironment setup code to the fuzz target to properly set up libicu
before fuzzing. This follows the approach taken in
https://crbug.com/754996#c15

Bug: 900811
Change-Id: Iebb7a7b7e8fac6ae6a089da1d51d2d85846b9967
Reviewed-on: https://chromium-review.googlesource.com/c/1318735Reviewed-by: default avatarAbhishek Arya <inferno@chromium.org>
Reviewed-by: default avatarVaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Commit-Queue: Abhishek Arya <inferno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605675}
parent 4dbfae51
......@@ -536,6 +536,7 @@ if (use_libfuzzer) {
":browser",
":proto",
"//base:base",
"//base:i18n",
"//third_party/libprotobuf-mutator",
]
}
......
......@@ -4,12 +4,20 @@
#include <stdlib.h>
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
#include "components/password_manager/core/browser/android_affiliation/lookup_affiliation_response_parser.h"
#include "testing/libfuzzer/proto/lpm_interface.h"
namespace password_manager {
namespace {
struct IcuEnvironment {
IcuEnvironment() { CHECK(base::i18n::InitializeICU()); }
// used by ICU integration.
base::AtExitManager at_exit_manager;
};
// We run ParseLookupAffiliationResponse twice with two hardcoded vectors of
// FacetURI. This approach can be extended to generating not only
// LookupAffiliationResponse, but also the vector of FacetURI.
......@@ -17,6 +25,8 @@ namespace {
// https://crrev.com/c/1131185/1/components/password_manager/core/browser/android_affiliation/lookup_affiliation_response_parser_fuzzer.cc#25
DEFINE_BINARY_PROTO_FUZZER(
const affiliation_pb::LookupAffiliationResponse& response) {
static IcuEnvironment env;
AffiliationFetcherDelegate::Result result;
std::vector<FacetURI> uris;
......
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