Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Unified Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp

Issue 2520403002: Add a configurable parse-depth limit when parsing JFV headers, and use it for Feature-Policy Header (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/json/JSONParserFuzzer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
diff --git a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
index a0932795b5399f60296a216a2124ecbecee861e9..51cabe384318c6df08f81d54e45eccead7a43177 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
@@ -198,7 +198,10 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
void FeaturePolicy::setHeaderPolicy(const String& policy,
Vector<String>* messages) {
DCHECK(m_headerWhitelists.isEmpty());
- std::unique_ptr<JSONArray> policyJSON = parseJSONHeader(policy);
+ // Use a reasonable parse depth limit; the actual maximum depth is only going
+ // to be 4 for a valid policy, but we'll give the featurePolicyParser a chance
+ // to report more specific errors, unless the string is really invalid.
+ std::unique_ptr<JSONArray> policyJSON = parseJSONHeader(policy, 50);
if (!policyJSON) {
if (messages)
messages->append("Unable to parse header");
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/json/JSONParserFuzzer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698