Commit 1650ecd0 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Add fuzzer for OmniboxView::SanitizeTextForPaste

I made a fuzzer for this because this code is kind of complex.

Also, the user's clipboard can contain pretty arbitrary data, so we
want to validate we can handle all inputs with no problems.

Change-Id: Ifaa25d47d5cdc247bf7f73425011bab8deadd135
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869075Reviewed-by: default avatarKevin Bailey <krb@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707540}
parent 40de9f5d
......@@ -210,6 +210,7 @@ jumbo_static_library("browser") {
public_deps = [
"//base",
"//base:i18n",
"//components/history/core/browser",
"//components/omnibox/common",
"//components/omnibox/resources:omnibox_resources",
......@@ -220,7 +221,6 @@ jumbo_static_library("browser") {
deps = [
":buildflags",
":in_memory_url_index_cache_proto",
"//base:i18n",
"//components/bookmarks/browser",
"//components/component_updater",
"//components/favicon/core",
......@@ -467,3 +467,13 @@ fuzzer_test("autocomplete_input_fuzzer") {
"//third_party/metrics_proto:metrics_proto",
]
}
fuzzer_test("omnibox_view_fuzzer") {
sources = [
"omnibox_view_fuzzer.cc",
]
deps = [
":browser",
"//base",
]
}
// 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 "components/omnibox/browser/omnibox_view.h"
#include <stddef.h>
#include <stdint.h>
#include "base/strings/string16.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// This fuzzer creates a random UTF16 string to represent clipboard contents.
base::string16 s(reinterpret_cast<const base::string16::value_type*>(data),
size / sizeof(base::string16::value_type));
OmniboxView::SanitizeTextForPaste(s);
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