diff options
author | Matt Sarett <msarett@google.com> | 2016-10-17 17:43:23 +0000 |
---|---|---|
committer | Matt Sarett <msarett@google.com> | 2016-10-17 17:43:32 +0000 |
commit | af017418b369fd14cb009c5f4c82683fb59f6c87 (patch) | |
tree | c85e576c7f72fe8ac089b12b090842cff653c9f6 | |
parent | 5238343ab27a9f42983b6c79f199416a5ae58542 (diff) |
Revert "Avoid integer overflow in SkIcoCodec"
This reverts commit 20cba06a4bc9bde60b2dc37907d11ca81ba35ce8.
Reason for revert: <INSERT REASONING HERE>
TBR=msarett@google.com,scroggo@google.com,kjlubick@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: Id8f48a90a7dc620f9c0ee2f419d14bae2b0c1e7e
Reviewed-on: https://skia-review.googlesource.com/3564
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
-rw-r--r-- | resources/invalid_images/int_overflow.ico | bin | 323 -> 0 bytes | |||
-rw-r--r-- | src/codec/SkIcoCodec.cpp | 9 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 7 |
3 files changed, 4 insertions, 12 deletions
diff --git a/resources/invalid_images/int_overflow.ico b/resources/invalid_images/int_overflow.ico Binary files differdeleted file mode 100644 index 24a7c701f9..0000000000 --- a/resources/invalid_images/int_overflow.ico +++ /dev/null diff --git a/src/codec/SkIcoCodec.cpp b/src/codec/SkIcoCodec.cpp index d01904dc1b..63b72c4039 100644 --- a/src/codec/SkIcoCodec.cpp +++ b/src/codec/SkIcoCodec.cpp @@ -157,12 +157,11 @@ SkCodec* SkIcoCodec::NewFromStream(SkStream* stream) { } // Use the largest codec as a "suggestion" for image info - size_t maxSize = 0; - int maxIndex = 0; - for (int i = 0; i < codecs->count(); i++) { + uint32_t maxSize = 0; + uint32_t maxIndex = 0; + for (int32_t i = 0; i < codecs->count(); i++) { SkImageInfo info = codecs->operator[](i)->getInfo(); - size_t size = info.getSafeSize(info.minRowBytes()); - + uint32_t size = info.width() * info.height(); if (size > maxSize) { maxSize = size; maxIndex = i; diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index a6058a9c35..4d18c61860 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -1362,10 +1362,3 @@ DEF_TEST(Codec_rowsDecoded, r) { REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput); REPORTER_ASSERT(r, rowsDecoded == 0); } - -DEF_TEST(Codec_IcoIntOverflow, r) { - // ASAN will complain if there is an issue. - SkBitmap bitmap; - const bool success = GetResourceAsBitmap("invalid_images/int_overflow.ico", &bitmap); - REPORTER_ASSERT(r, !success); -} |