From d8335d98a4c056ab97c5cdff1e95a7fa2c7dfc10 Mon Sep 17 00:00:00 2001 From: mkwst Date: Fri, 24 Jul 2015 22:18:48 -0700 Subject: Teach IPC about 'url::Origin'. We'll need to pass Origin objects back and forth between the renderer and browser processes. This patch teaches IPC about the object in order to make that possible. BUG=512731 Review URL: https://codereview.chromium.org/1251063002 Cr-Commit-Position: refs/heads/master@{#340399} --- tools/ipc_fuzzer/fuzzer/fuzzer.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tools/ipc_fuzzer') diff --git a/tools/ipc_fuzzer/fuzzer/fuzzer.cc b/tools/ipc_fuzzer/fuzzer/fuzzer.cc index 2af05d9..f0676ae 100644 --- a/tools/ipc_fuzzer/fuzzer/fuzzer.cc +++ b/tools/ipc_fuzzer/fuzzer/fuzzer.cc @@ -1790,6 +1790,28 @@ struct FuzzTraits { }; template <> +struct FuzzTraits { + static bool Fuzz(url::Origin* p, Fuzzer* fuzzer) { + std::string scheme = p->scheme(); + std::string host = p->host(); + uint16 port = p->port(); + if (!FuzzParam(&scheme, fuzzer)) + return false; + if (!FuzzParam(&host, fuzzer)) + return false; + if (!FuzzParam(&port, fuzzer)) + return false; + *p = url::Origin::UnsafelyCreateOriginWithoutNormalization(scheme, host, + port); + + // Force a unique origin 1% of the time: + if (RandInRange(100) == 1) + *p = url::Origin(); + return true; + } +}; + +template <> struct FuzzTraits { static bool Fuzz(url::DeprecatedSerializedOrigin* p, Fuzzer* fuzzer) { std::string origin = p->string(); -- cgit v1.1