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

Unified Diff: src/core/SkPictureData.cpp

Issue 718103002: detect bad bitmaps during deserialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: return true (but empty) if we just didn't recognize the codec type Created 6 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 | src/core/SkReadBuffer.cpp » ('j') | src/core/SkReadBuffer.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureData.cpp
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 896c2e6bf324fcd5f17b9ed9c731fb7736086b6b..bc152829189b098c2eecd0014329bb7b3ce3ad60 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -395,6 +395,7 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
return false;
}
+ /* Should we use SkValidatingReadBuffer instead? */
scroggo 2014/11/12 18:24:47 If we're going to check isValid, absolutely! Other
SkReadBuffer buffer(storage.get(), size);
buffer.setFlags(pictInfoFlagsToReadBufferFlags(fInfo.fFlags));
buffer.setVersion(fInfo.fVersion);
@@ -403,13 +404,16 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
fTFPlayback.setupBuffer(buffer);
buffer.setBitmapDecoder(proc);
- while (!buffer.eof()) {
+ while (!buffer.eof() && buffer.isValid()) {
tag = buffer.readUInt();
size = buffer.readUInt();
if (!this->parseBufferTag(buffer, tag, size)) {
return false;
}
}
+ if (!buffer.isValid()) {
scroggo 2014/11/12 18:24:47 Do we need both checks? Is it possible for isVali
+ return false;
+ }
SkDEBUGCODE(haveBuffer = true;)
} break;
}
@@ -424,8 +428,11 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer,
fBitmaps = SkTRefArray<SkBitmap>::Create(size);
for (int i = 0; i < count; ++i) {
SkBitmap* bm = &fBitmaps->writableAt(i);
- buffer.readBitmap(bm);
- bm->setImmutable();
+ if (buffer.readBitmap(bm)) {
+ bm->setImmutable();
+ } else {
+ return false;
+ }
}
} break;
case SK_PICT_PAINT_BUFFER_TAG: {
« no previous file with comments | « no previous file | src/core/SkReadBuffer.cpp » ('j') | src/core/SkReadBuffer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698