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

Unified Diff: src/images/SkImageDecoder_libico.cpp

Issue 656673005: Don't read random data in ICO check. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Respond to comments. Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libico.cpp
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index 4d19714a11b20c134aa9e6e38c3849529b50f798..cd8a292edc149d70f8cf46f6657e5df5052c0691 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -405,16 +405,13 @@ DEFINE_DECODER_CREATOR(ICOImageDecoder);
static bool is_ico(SkStreamRewindable* stream) {
// Check to see if the first four bytes are 0,0,1,0
// FIXME: Is that required and sufficient?
- SkAutoMalloc autoMal(4);
- unsigned char* buf = (unsigned char*)autoMal.get();
- stream->read((void*)buf, 4);
- int reserved = read2Bytes(buf, 0);
- int type = read2Bytes(buf, 2);
- if (reserved != 0 || type != 1) {
- // This stream does not represent an ICO image.
+ char buf[4];
+ if (stream->read((void*)buf, 4) != 4) {
return false;
}
- return true;
+ int reserved = read2Bytes(buf, 0);
+ int type = read2Bytes(buf, 2);
+ return 0 == reserved && 1 == type;
}
static SkImageDecoder* sk_libico_dfactory(SkStreamRewindable* stream) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698