diff options
author | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 13:57:53 +0000 |
---|---|---|
committer | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 13:57:53 +0000 |
commit | 7b372b5a2c490cbdca175bb8091d01bf455c7b22 (patch) | |
tree | a4a1a8978cc68e52092b236c9bb7911b8e504707 /chrome/tools | |
parent | c2a52bf823cd88df5b8e46f89ad7a4e7bc2e20ca (diff) | |
download | chromium_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-x | chrome/tools/build/generate_policy_source.py | 12 |
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') |