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

Unified Diff: include/core/SkReader32.h

Issue 41253002: Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Revert back to Patch Set 4 Created 7 years, 2 months 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
Index: include/core/SkReader32.h
diff --git a/include/core/SkReader32.h b/include/core/SkReader32.h
index 7a8d22a80c166c82539f05fe9d83186269416762..71101c333474bb70ad642052d0f3025fa23df924 100644
--- a/include/core/SkReader32.h
+++ b/include/core/SkReader32.h
@@ -107,13 +107,13 @@ public:
uint32_t readU32() { return this->readInt(); }
void readPath(SkPath* path) {
- size_t size = path->readFromMemory(this->peek());
+ size_t size = path->readFromMemory(this->peek(), this->available());
SkASSERT(SkAlign4(size) == size);
(void)this->skip(size);
reed1 2013/10/29 19:42:58 if readFromMemory returns 0 (e.g. truncated stream
sugoi1 2013/10/29 20:16:47 Ok (I had to think about it a little). This would
Stephen White 2013/10/29 20:40:54 Reading out-of-bounds doesn't sound good. Is that
}
void readMatrix(SkMatrix* matrix) {
- size_t size = matrix->readFromMemory(this->peek());
+ size_t size = matrix->readFromMemory(this->peek(), this->available());
SkASSERT(SkAlign4(size) == size);
(void)this->skip(size);
}
@@ -124,7 +124,7 @@ public:
}
void readRegion(SkRegion* rgn) {
- size_t size = rgn->readFromMemory(this->peek());
+ size_t size = rgn->readFromMemory(this->peek(), this->available());
SkASSERT(SkAlign4(size) == size);
(void)this->skip(size);
}
« include/core/SkMatrix.h ('K') | « include/core/SkPath.h ('k') | include/core/SkRegion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698