summaryrefslogtreecommitdiffstats
path: root/chrome/tools
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 13:57:53 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 13:57:53 +0000
commit7b372b5a2c490cbdca175bb8091d01bf455c7b22 (patch)
treea4a1a8978cc68e52092b236c9bb7911b8e504707 /chrome/tools
parentc2a52bf823cd88df5b8e46f89ad7a4e7bc2e20ca (diff)
downloadchromium_src-7b372b5a2c490cbdca175bb8091d01bf455c7b22.zip
chromium_src-7b372b5a2c490cbdca175bb8091d01bf455c7b22.tar.gz
chromium_src-7b372b5a2c490cbdca175bb8091d01bf455c7b22.tar.bz2
Fix crash when a JSON cloud policy's value is invalid
When a JSON cloud policy is set to an invalid value, DecodeJson() returns a NULL pointer, which causes the PolicyMap::Entry for this policy to have a |value| member of NULL. This is unsupported. The |value| member must always be non-NULL. The CL fixes the crash by not adding a PolicyMap::Entry when the policy value cannot be parsed. BUG=None TEST=Manual Review URL: https://codereview.chromium.org/96903004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rwxr-xr-xchrome/tools/build/generate_policy_source.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/chrome/tools/build/generate_policy_source.py b/chrome/tools/build/generate_policy_source.py
index 9a89478d..d048c0d 100755
--- a/chrome/tools/build/generate_policy_source.py
+++ b/chrome/tools/build/generate_policy_source.py
@@ -722,12 +722,16 @@ def _WritePolicyCode(f, policy):
' if (do_set) {\n')
f.write(' base::Value* value = %s;\n' %
(_CreateValue(policy.policy_type, 'policy_proto.value()')))
- f.write(' ExternalDataFetcher* external_data_fetcher = %s;\n' %
+ # TODO(bartfab): |value| == NULL indicates that the policy value could not be
+ # parsed successfully. Surface such errors in the UI.
+ f.write(' if (value) {\n')
+ f.write(' ExternalDataFetcher* external_data_fetcher = %s;\n' %
_CreateExternalDataFetcher(policy.policy_type, policy.name))
- f.write(' map->Set(key::k%s, level, POLICY_SCOPE_USER,\n' %
+ f.write(' map->Set(key::k%s, level, POLICY_SCOPE_USER,\n' %
policy.name)
- f.write(' value, external_data_fetcher);\n')
- f.write(' }\n'
+ f.write(' value, external_data_fetcher);\n'
+ ' }\n'
+ ' }\n'
' }\n'
' }\n')