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

Issue 2728773005: Check Swaps and MergeDictionary for base::Value (Closed)

Created:
3 years, 9 months ago by vabr (Chromium)
Modified:
3 years, 9 months ago
Reviewers:
jdoerrie, brettw
CC:
chromium-reviews, vmpstr+watch_chromium.org, jdoerrie
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Check Swaps and MergeDictionary for base::Value The following is a dangerous practice: 1: DictionaryValue d; 2: Value *p = &d; 3: *p = Value(1.234); 4: DictionaryValue().Swap(&d); After line 3, |d| is no longer a DictionaryValue. Before r451296, it caused no bad memory access, because the storage for the double and for the dictionary did not overlap. After that CL, this code would crash. In any case, it is dangerous. Similar issue is there for DictionaryValue::MergeDictionary and ListValue::Swap. This issue is only temporary, because DictionaryValue will eventually become just Value. But until then, the code needs to be sure to avoid such scenarios. Therefore this CL introduces CHECKS for the correct value types. The CL also introduces two more CHECKS in Internal*AssignFrom to prevent executing a desctructor on an arbitrary address. All the above are CHECKS, as opposed to DCHECKS, because if the checked conditions do not hold, execution of arbitrary parts of memory might be possible. BUG=697817 Review-Url: https://codereview.chromium.org/2728773005 Cr-Commit-Position: refs/heads/master@{#455288} Committed: https://chromium.googlesource.com/chromium/src/+/182756aeb9ef4240cace58875e71d42a7402711c

Patch Set 1 #

Patch Set 2 : CHECKS #

Total comments: 4

Patch Set 3 : Add ...SameType #

Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -8 lines) Patch
M base/values.h View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M base/values.cc View 1 2 7 chunks +9 lines, -6 lines 0 comments Download

Messages

Total messages: 21 (15 generated)
vabr (Chromium)
Hi Brett, While I'm not sure how much this is related to the crash in ...
3 years, 9 months ago (2017-03-02 23:25:07 UTC) #4
jdoerrie
LGTM, as you said, this should only be temporary. https://codereview.chromium.org/2728773005/diff/20001/base/values.cc File base/values.cc (right): https://codereview.chromium.org/2728773005/diff/20001/base/values.cc#newcode538 base/values.cc:538: ...
3 years, 9 months ago (2017-03-06 12:34:43 UTC) #9
vabr (Chromium)
Thanks, Jan! Brett -- a gentle ping for a review. :) Cheers, Vaclav https://codereview.chromium.org/2728773005/diff/20001/base/values.cc File ...
3 years, 9 months ago (2017-03-06 17:09:32 UTC) #14
brettw
lgtm
3 years, 9 months ago (2017-03-07 21:40:17 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2728773005/40001
3 years, 9 months ago (2017-03-07 21:41:20 UTC) #18
commit-bot: I haz the power
3 years, 9 months ago (2017-03-07 23:35:15 UTC) #21
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/chromium/src/+/182756aeb9ef4240cace58875e71...

Powered by Google App Engine
This is Rietveld 408576698