Bug 1249578 (Part 2) - Add a test that decoding ICOs with a size mismatch between the BIH header and the ICO directory entry fails. r=njn a=abillings
authorSeth Fowler <mark.seth.fowler@gmail.com>
Mon, 20 Jun 2016 20:27:39 -0700
changeset 341674 08127897283dd05ae78e32ed71ce727bdb39285c
parent 341673 29f08288ee29cb9c21b53576de7617b5623995fb
child 341675 4ce5bd90da474685cf582e46109cbde62b69bb2d
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, abillings
bugs1249578
milestone49.0a2
Bug 1249578 (Part 2) - Add a test that decoding ICOs with a size mismatch between the BIH header and the ICO directory entry fails. r=njn a=abillings
image/test/gtest/Common.cpp
image/test/gtest/Common.h
image/test/gtest/TestDecoders.cpp
image/test/gtest/corrupt-with-bad-bmp-height.ico
image/test/gtest/corrupt-with-bad-bmp-width.ico
image/test/gtest/moz.build
--- a/image/test/gtest/Common.cpp
+++ b/image/test/gtest/Common.cpp
@@ -480,16 +480,32 @@ ImageTestCase GreenFirstFrameAnimatedPNG
 }
 
 ImageTestCase CorruptTestCase()
 {
   return ImageTestCase("corrupt.jpg", "image/jpeg", IntSize(100, 100),
                        TEST_CASE_HAS_ERROR);
 }
 
+ImageTestCase CorruptICOWithBadBMPWidthTestCase()
+{
+  // This ICO contains a BMP icon which has a width that doesn't match the size
+  // listed in the corresponding ICO directory entry.
+  return ImageTestCase("corrupt-with-bad-bmp-width.ico", "image/x-icon",
+                       IntSize(100, 100), TEST_CASE_HAS_ERROR);
+}
+
+ImageTestCase CorruptICOWithBadBMPHeightTestCase()
+{
+  // This ICO contains a BMP icon which has a height that doesn't match the size
+  // listed in the corresponding ICO directory entry.
+  return ImageTestCase("corrupt-with-bad-bmp-height.ico", "image/x-icon",
+                       IntSize(100, 100), TEST_CASE_HAS_ERROR);
+}
+
 ImageTestCase TransparentPNGTestCase()
 {
   return ImageTestCase("transparent.png", "image/png", IntSize(32, 32),
                        TEST_CASE_IS_TRANSPARENT);
 }
 
 ImageTestCase TransparentGIFTestCase()
 {
--- a/image/test/gtest/Common.h
+++ b/image/test/gtest/Common.h
@@ -322,16 +322,18 @@ ImageTestCase GreenJPGTestCase();
 ImageTestCase GreenBMPTestCase();
 ImageTestCase GreenICOTestCase();
 ImageTestCase GreenIconTestCase();
 
 ImageTestCase GreenFirstFrameAnimatedGIFTestCase();
 ImageTestCase GreenFirstFrameAnimatedPNGTestCase();
 
 ImageTestCase CorruptTestCase();
+ImageTestCase CorruptICOWithBadBMPWidthTestCase();
+ImageTestCase CorruptICOWithBadBMPHeightTestCase();
 
 ImageTestCase TransparentPNGTestCase();
 ImageTestCase TransparentGIFTestCase();
 ImageTestCase FirstFramePaddingGIFTestCase();
 ImageTestCase NoFrameDelayGIFTestCase();
 
 ImageTestCase TransparentBMPWhenBMPAlphaEnabledTestCase();
 ImageTestCase RLE4BMPTestCase();
--- a/image/test/gtest/TestDecoders.cpp
+++ b/image/test/gtest/TestDecoders.cpp
@@ -344,8 +344,27 @@ TEST(ImageDecoders, CorruptSingleChunk)
 {
   CheckDecoderSingleChunk(CorruptTestCase());
 }
 
 TEST(ImageDecoders, CorruptMultiChunk)
 {
   CheckDecoderMultiChunk(CorruptTestCase());
 }
+TEST(ImageDecoders, CorruptICOWithBadBMPWidthSingleChunk)
+{
+  CheckDecoderSingleChunk(CorruptICOWithBadBMPWidthTestCase());
+}
+
+TEST(ImageDecoders, CorruptICOWithBadBMPWidthMultiChunk)
+{
+  CheckDecoderMultiChunk(CorruptICOWithBadBMPWidthTestCase());
+}
+
+TEST(ImageDecoders, CorruptICOWithBadBMPHeightSingleChunk)
+{
+  CheckDecoderSingleChunk(CorruptICOWithBadBMPHeightTestCase());
+}
+
+TEST(ImageDecoders, CorruptICOWithBadBMPHeightMultiChunk)
+{
+  CheckDecoderMultiChunk(CorruptICOWithBadBMPHeightTestCase());
+}
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ee4a90fcd78ffea0c28ed23835983b6928206be2
GIT binary patch
literal 41663
zc%1FXp$&jQ5Jb_zf+RsBDT89JEEI}LXbX;9as{B@f7un23{@$qf6a9!OOmZ#opPt`
zU;B~FQ@h>+000000000000000000000000000000000000000000000004B7B>iZ7
E0YC5CL;wH)
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..aa4051cd07ab64ca2e2f755c3cf70d8d28781ceb
GIT binary patch
literal 41663
zc%1FXp$&jQ5Jb_zf+RsBDT7|PvQQ{Wp({9Y2?e0vf0-4VbX6&-cg}evQ<9}_tGm+v
zZ|k0nL)+I4000000000000000000000000000000000000000000000004X>N%~R$
E0OE|>MF0Q*
--- a/image/test/gtest/moz.build
+++ b/image/test/gtest/moz.build
@@ -25,16 +25,18 @@ if CONFIG['MOZ_ENABLE_SKIA']:
     ]
 
 SOURCES += [
     # Can't be unified because it manipulates the preprocessor environment.
     'TestDownscalingFilterNoSkia.cpp',
 ]
 
 TEST_HARNESS_FILES.gtest += [
+    'corrupt-with-bad-bmp-height.ico',
+    'corrupt-with-bad-bmp-width.ico',
     'corrupt.jpg',
     'downscaled.bmp',
     'downscaled.gif',
     'downscaled.ico',
     'downscaled.icon',
     'downscaled.jpg',
     'downscaled.png',
     'first-frame-green.gif',