From c6afbd59c997c2b64f11abdd1eaef71ae8ea2ddc Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Fri, 07 Jun 2019 18:11:15 +0000 Subject: [PATCH] GCC: FeaturePolicyParser ParseValueForFuzzer is not in anonymous namespace Compilation fails because we are declaring ParseValueForFuzzer as friend method, but we are declaring it is in anonymous namespace. Moving to global namespace still fails (in this case in Clang). So final solution is making it a public static method of FeaturePolicyParser. Bug: 819294 Change-Id: Iea307cb6faef675b748d6eb5da2175dcbb17fdc7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1645223 Commit-Queue: José Dapena Paz Reviewed-by: Luna Lu Cr-Commit-Position: refs/heads/master@{#667228} --- diff --git a/third_party/blink/renderer/core/feature_policy/feature_policy_parser.cc b/third_party/blink/renderer/core/feature_policy/feature_policy_parser.cc index f1c9594..bae91a1 100644 --- a/third_party/blink/renderer/core/feature_policy/feature_policy_parser.cc +++ b/third_party/blink/renderer/core/feature_policy/feature_policy_parser.cc @@ -323,6 +323,13 @@ return value; } +void FeaturePolicyParser::ParseValueForFuzzer( + blink::mojom::PolicyValueType feature_type, + const WTF::String& value_string) { + bool ok; + ParseValueForType(feature_type, value_string, &ok); +} + bool IsFeatureDeclared(mojom::FeaturePolicyFeature feature, const ParsedFeaturePolicy& policy) { return std::any_of(policy.begin(), policy.end(), diff --git a/third_party/blink/renderer/core/feature_policy/feature_policy_parser.h b/third_party/blink/renderer/core/feature_policy/feature_policy_parser.h index fd25d90..8aa7323 100644 --- a/third_party/blink/renderer/core/feature_policy/feature_policy_parser.h +++ b/third_party/blink/renderer/core/feature_policy/feature_policy_parser.h @@ -16,9 +16,6 @@ #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" -// Forward declare for friendship. -void ParseValueForFuzzer(blink::mojom::PolicyValueType, const WTF::String&); - namespace blink { class Document; @@ -79,8 +76,10 @@ const FeatureNameMap& feature_names, ExecutionContext* execution_context = nullptr); + // Used for LLVM fuzzer test + static void ParseValueForFuzzer(mojom::PolicyValueType, const String&); + private: - friend void ::ParseValueForFuzzer(mojom::PolicyValueType, const String&); static PolicyValue GetFallbackValueForFeature( mojom::FeaturePolicyFeature feature); static PolicyValue ParseValueForType(mojom::PolicyValueType feature_type, diff --git a/third_party/blink/renderer/core/feature_policy/feature_policy_value_fuzzer.cc b/third_party/blink/renderer/core/feature_policy/feature_policy_value_fuzzer.cc index 7f8e6aa..1455636 100644 --- a/third_party/blink/renderer/core/feature_policy/feature_policy_value_fuzzer.cc +++ b/third_party/blink/renderer/core/feature_policy/feature_policy_value_fuzzer.cc @@ -13,19 +13,12 @@ #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" -void ParseValueForFuzzer(blink::mojom::PolicyValueType feature_type, - const WTF::String& value_string) { - bool ok; - blink::FeaturePolicyParser::ParseValueForType(feature_type, value_string, - &ok); -} - extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { static blink::BlinkFuzzerTestSupport test_support = blink::BlinkFuzzerTestSupport(); - ParseValueForFuzzer(blink::mojom::PolicyValueType::kBool, - WTF::String(data, size)); - ParseValueForFuzzer(blink::mojom::PolicyValueType::kDecDouble, - WTF::String(data, size)); + blink::FeaturePolicyParser::ParseValueForFuzzer( + blink::mojom::PolicyValueType::kBool, WTF::String(data, size)); + blink::FeaturePolicyParser::ParseValueForFuzzer( + blink::mojom::PolicyValueType::kDecDouble, WTF::String(data, size)); return 0; }