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

Issue 41253002: Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. (Closed)

Created:
7 years, 2 months ago by sugoi1
Modified:
7 years ago
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. BUG= R=reed@google.com Committed: https://code.google.com/p/skia/source/detail?r=12114 Committed: https://code.google.com/p/skia/source/detail?r=12119 Committed: http://code.google.com/p/skia/source/detail?r=12130

Patch Set 1 #

Total comments: 4

Patch Set 2 : Adding length info to read operations #

Total comments: 2

Patch Set 3 : Added SkRBufferWithSizeCheck #

Patch Set 4 : Added better descriptions #

Patch Set 5 : Removing SkMatrix's writeToMemory, readFromMemory #

Total comments: 4

Patch Set 6 : Removed SkRegion's writeToMemory()/readFromMemory() #

Patch Set 7 : Revert back to Patch Set 4 #

Total comments: 5

Patch Set 8 : Fixed comments and added tests #

Total comments: 4

Patch Set 9 : Templatized read functions for readFromMemory users #

Total comments: 5

Patch Set 10 : Changed an assert into a success test #

Patch Set 11 : Made sure size can't exceed available memory #

Total comments: 1

Patch Set 12 : Merging tests #

Patch Set 13 : Added align to 4 tests #

Total comments: 2

Patch Set 14 : Templatized tests #

Patch Set 15 : Windows warnings fixed #

Patch Set 16 : Fixed non multiple of 4 buffer size #

Total comments: 1

Patch Set 17 : Added checks so that we don't read uninitialized memory (debug only) #

Patch Set 18 : Adding validation before memory allocation in SkRegion::readFromMemory #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+333 lines, -189 lines) Patch
M include/core/SkMatrix.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +10 lines, -3 lines 0 comments Download
M include/core/SkPath.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +9 lines, -6 lines 0 comments Download
M include/core/SkRRect.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +11 lines, -5 lines 0 comments Download
M include/core/SkReader32.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +17 lines, -15 lines 0 comments Download
M include/core/SkRegion.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +8 lines, -5 lines 0 comments Download
M samplecode/SampleRegion.cpp View 1 6 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkBuffer.h View 1 2 3 chunks +24 lines, -2 lines 0 comments Download
M src/core/SkBuffer.cpp View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
M src/core/SkMatrix.cpp View 1 2 3 4 5 6 7 1 chunk +11 lines, -6 lines 0 comments Download
M src/core/SkPath.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +12 lines, -8 lines 0 comments Download
M src/core/SkPicturePlayback.cpp View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -1 line 0 comments Download
M src/core/SkRRect.cpp View 1 2 3 4 5 6 7 8 2 chunks +6 lines, -2 lines 0 comments Download
M src/core/SkRegion.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 chunks +17 lines, -11 lines 0 comments Download
M src/core/SkValidatingReadBuffer.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +17 lines, -6 lines 0 comments Download
M tests/MatrixTest.cpp View 1 2 3 4 5 6 7 1 chunk +6 lines, -5 lines 0 comments Download
M tests/PathTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +3 lines, -3 lines 0 comments Download
M tests/SerializationTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +172 lines, -110 lines 1 comment Download

Messages

Total messages: 43 (0 generated)
sugoi1
https://codereview.chromium.org/41253002/diff/1/src/core/SkPathRef.cpp File src/core/SkPathRef.cpp (right): https://codereview.chromium.org/41253002/diff/1/src/core/SkPathRef.cpp#newcode158 src/core/SkPathRef.cpp:158: // the buffer's peek forward (while making sure we ...
7 years, 2 months ago (2013-10-24 19:51:38 UTC) #1
sugoi1
On 2013/10/24 19:51:38, sugoi1 wrote: > https://codereview.chromium.org/41253002/diff/1/src/core/SkPathRef.cpp > File src/core/SkPathRef.cpp (right): > > https://codereview.chromium.org/41253002/diff/1/src/core/SkPathRef.cpp#newcode158 > ...
7 years, 2 months ago (2013-10-24 20:41:57 UTC) #2
reed1
Not a fan of teaching our (very) core classes about readbuffers. Why this change? https://codereview.chromium.org/41253002/diff/1/include/core/SkMatrix.h ...
7 years, 2 months ago (2013-10-24 20:51:19 UTC) #3
sugoi1
On 2013/10/24 20:51:19, reed1 wrote: > Not a fan of teaching our (very) core classes ...
7 years, 2 months ago (2013-10-25 11:49:37 UTC) #4
sugoi1
Ok, here's the new solution. I think it's cleaner and it makes more sense than ...
7 years, 1 month ago (2013-10-25 12:31:12 UTC) #5
reed1
General thought about this "readFromMemory" pattern. Seems like we should *not* support the notion of ...
7 years, 1 month ago (2013-10-25 14:42:45 UTC) #6
sugoi1
https://codereview.chromium.org/41253002/diff/100001/include/core/SkMatrix.h File include/core/SkMatrix.h (right): https://codereview.chromium.org/41253002/diff/100001/include/core/SkMatrix.h#newcode563 include/core/SkMatrix.h:563: // return the number of bytes read On 2013/10/25 ...
7 years, 1 month ago (2013-10-25 14:59:02 UTC) #7
sugoi1
On 2013/10/25 14:42:45, reed1 wrote: > General thought about this "readFromMemory" pattern. > > Seems ...
7 years, 1 month ago (2013-10-25 15:08:58 UTC) #8
mtklein
On 2013/10/25 15:08:58, sugoi1 wrote: > On 2013/10/25 14:42:45, reed1 wrote: > > General thought ...
7 years, 1 month ago (2013-10-25 16:07:47 UTC) #9
sugoi1
On 2013/10/25 16:07:47, mtklein wrote: > On 2013/10/25 15:08:58, sugoi1 wrote: > > On 2013/10/25 ...
7 years, 1 month ago (2013-10-25 17:01:31 UTC) #10
sugoi1
On 2013/10/25 17:01:31, sugoi1 wrote: > On 2013/10/25 16:07:47, mtklein wrote: > > On 2013/10/25 ...
7 years, 1 month ago (2013-10-25 18:05:07 UTC) #11
mtklein
Yeah, do you think you could try SkPath? SkMatrix is sort of too trivial to ...
7 years, 1 month ago (2013-10-25 18:11:49 UTC) #12
sugoi1
https://codereview.chromium.org/41253002/diff/240001/include/core/SkReader32.h File include/core/SkReader32.h (right): https://codereview.chromium.org/41253002/diff/240001/include/core/SkReader32.h#newcode116 include/core/SkReader32.h:116: matrix->setAll(this->readScalar(), this->readScalar(), this->readScalar(), On 2013/10/25 18:11:49, mtklein wrote: > ...
7 years, 1 month ago (2013-10-25 18:27:20 UTC) #13
sugoi1
On 2013/10/25 18:11:49, mtklein wrote: > Yeah, do you think you could try SkPath? SkMatrix ...
7 years, 1 month ago (2013-10-25 18:28:01 UTC) #14
sugoi1
Ok, so I did SkRegion first, because it seemed a bit simpler. Here's what I ...
7 years, 1 month ago (2013-10-25 19:46:14 UTC) #15
sugoi1
Ok, so after all this, it seems that removing readFromMemory / writeToMemory will be hard ...
7 years, 1 month ago (2013-10-25 21:02:25 UTC) #16
reed1
https://codereview.chromium.org/41253002/diff/650001/include/core/SkMatrix.h File include/core/SkMatrix.h (right): https://codereview.chromium.org/41253002/diff/650001/include/core/SkMatrix.h#newcode570 include/core/SkMatrix.h:570: uint32_t readFromMemory(const void* buffer, uint32_t length); size_t ? https://codereview.chromium.org/41253002/diff/650001/include/core/SkReader32.h ...
7 years, 1 month ago (2013-10-29 19:42:57 UTC) #17
sugoi1
https://codereview.chromium.org/41253002/diff/650001/include/core/SkMatrix.h File include/core/SkMatrix.h (right): https://codereview.chromium.org/41253002/diff/650001/include/core/SkMatrix.h#newcode570 include/core/SkMatrix.h:570: uint32_t readFromMemory(const void* buffer, uint32_t length); On 2013/10/29 19:42:58, ...
7 years, 1 month ago (2013-10-29 20:16:46 UTC) #18
Stephen White
https://codereview.chromium.org/41253002/diff/650001/include/core/SkReader32.h File include/core/SkReader32.h (right): https://codereview.chromium.org/41253002/diff/650001/include/core/SkReader32.h#newcode112 include/core/SkReader32.h:112: (void)this->skip(size); On 2013/10/29 20:16:47, sugoi1 wrote: > On 2013/10/29 ...
7 years, 1 month ago (2013-10-29 20:40:53 UTC) #19
sugoi1
Added tests, made changes from uint32_t to size_t and modified rrect, so that it is ...
7 years, 1 month ago (2013-10-30 15:21:41 UTC) #20
sugoi1
On 2013/10/29 20:40:53, Stephen White wrote: > Reading out-of-bounds doesn't sound good. Is that something ...
7 years, 1 month ago (2013-10-30 15:22:39 UTC) #21
reed1
thanks, this is getting better each time. I still want to be sure the semantics ...
7 years, 1 month ago (2013-10-30 15:37:07 UTC) #22
sugoi1
https://codereview.chromium.org/41253002/diff/760001/include/core/SkReader32.h File include/core/SkReader32.h (right): https://codereview.chromium.org/41253002/diff/760001/include/core/SkReader32.h#newcode109 include/core/SkReader32.h:109: void readPath(SkPath* path) { On 2013/10/30 15:37:07, reed1 wrote: ...
7 years, 1 month ago (2013-10-30 18:07:03 UTC) #23
reed1
https://codereview.chromium.org/41253002/diff/1060001/include/core/SkReader32.h File include/core/SkReader32.h (right): https://codereview.chromium.org/41253002/diff/1060001/include/core/SkReader32.h#newcode143 include/core/SkReader32.h:143: SkASSERT(SkAlign4(size) == size && success); not sure we can ...
7 years, 1 month ago (2013-10-30 18:10:20 UTC) #24
sugoi1
https://codereview.chromium.org/41253002/diff/1060001/include/core/SkReader32.h File include/core/SkReader32.h (right): https://codereview.chromium.org/41253002/diff/1060001/include/core/SkReader32.h#newcode143 include/core/SkReader32.h:143: SkASSERT(SkAlign4(size) == size && success); On 2013/10/30 18:10:21, reed1 ...
7 years, 1 month ago (2013-10-30 18:26:54 UTC) #25
reed1
On 2013/10/30 18:26:54, sugoi1 wrote: > https://codereview.chromium.org/41253002/diff/1060001/include/core/SkReader32.h > File include/core/SkReader32.h (right): > > https://codereview.chromium.org/41253002/diff/1060001/include/core/SkReader32.h#newcode143 > ...
7 years, 1 month ago (2013-10-30 18:38:00 UTC) #26
sugoi1
On 2013/10/30 18:38:00, reed1 wrote: > If skip can fail (e.g. we ask for too ...
7 years, 1 month ago (2013-10-30 18:56:17 UTC) #27
sugoi1
https://codereview.chromium.org/41253002/diff/1120001/include/core/SkReader32.h File include/core/SkReader32.h (right): https://codereview.chromium.org/41253002/diff/1120001/include/core/SkReader32.h#newcode142 include/core/SkReader32.h:142: bool success = (size > 0) && (size <= ...
7 years, 1 month ago (2013-10-31 15:47:47 UTC) #28
sugoi1
Merge tests together
7 years, 1 month ago (2013-11-01 18:15:41 UTC) #29
reed1
looking good to me. I think you correctly check that the returned size is a ...
7 years, 1 month ago (2013-11-01 18:27:21 UTC) #30
sugoi1
On 2013/11/01 18:27:21, reed1 wrote: > looking good to me. > > I think you ...
7 years, 1 month ago (2013-11-01 18:52:35 UTC) #31
sugoi1
On 2013/11/01 18:52:35, sugoi1 wrote: > On 2013/11/01 18:27:21, reed1 wrote: > > looking good ...
7 years, 1 month ago (2013-11-04 13:15:58 UTC) #32
reed1
thanks for the checks. lgtm but I think we could do a more concise job ...
7 years, 1 month ago (2013-11-04 14:26:53 UTC) #33
sugoi1
https://codereview.chromium.org/41253002/diff/1230001/tests/SerializationTest.cpp File tests/SerializationTest.cpp (right): https://codereview.chromium.org/41253002/diff/1230001/tests/SerializationTest.cpp#newcode13 tests/SerializationTest.cpp:13: // Test matrix serialization On 2013/11/04 14:26:54, reed1 wrote: ...
7 years, 1 month ago (2013-11-04 15:26:13 UTC) #34
reed1
danke lgtm
7 years, 1 month ago (2013-11-04 15:45:47 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/sugoi@chromium.org/41253002/1350001
7 years, 1 month ago (2013-11-04 16:00:52 UTC) #36
sugoi1
Committed patchset #15 manually as r12114 (presubmit successful).
7 years, 1 month ago (2013-11-04 16:18:24 UTC) #37
sugoi1
https://codereview.chromium.org/41253002/diff/1410001/tests/SerializationTest.cpp File tests/SerializationTest.cpp (right): https://codereview.chromium.org/41253002/diff/1410001/tests/SerializationTest.cpp#newcode111 tests/SerializationTest.cpp:111: SkValidatingReadBuffer buffer(dataWritten, bytesWritten - 4); This was a silly ...
7 years, 1 month ago (2013-11-04 18:41:36 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/sugoi@chromium.org/41253002/1410001
7 years, 1 month ago (2013-11-04 18:45:11 UTC) #39
sugoi1
Committed patchset #17 manually as r12119 (presubmit successful).
7 years, 1 month ago (2013-11-04 20:28:33 UTC) #40
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/sugoi@chromium.org/41253002/1570001
7 years, 1 month ago (2013-11-05 15:21:11 UTC) #41
commit-bot: I haz the power
Change committed as 12130
7 years, 1 month ago (2013-11-05 15:47:03 UTC) #42
bungeman-skia
7 years ago (2013-11-27 17:11:26 UTC) #43
Message was sent while issue was closed.
https://codereview.chromium.org/41253002/diff/1570001/tests/SerializationTest...
File tests/SerializationTest.cpp (right):

https://codereview.chromium.org/41253002/diff/1570001/tests/SerializationTest...
tests/SerializationTest.cpp:177: TestAlignment(&rrect, reporter);
This test is causing Valgrind to complain about SkRRect's readFromMemory
branching on uninitialized values. SkRRect starts out uninitialized; it requires
setXXX to be called before using it. Please see
https://code.google.com/p/skia/source/detail?r=12419 which fixes this (by
ensuring that all of the data in these tests are initialized).

Powered by Google App Engine
This is Rietveld 408576698