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 383747 13ce99eb20be5ebc3ff877ac0b1c12f88e9e4d67
parent 383746 be34b11bfd0748e1efac188ff72e71e8e5e7ff54
child 383748 dbcb78d8ca7469fa8e303eaeeecb17b51757df01
push id22092
push userbmo:dburns@mozilla.com
push dateMon, 04 Jul 2016 23:04:12 +0000
reviewersnjn, abillings
bugs1249578
milestone48.0
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
@@ -457,16 +457,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
@@ -297,16 +297,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
@@ -251,8 +251,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 0000000000000000000000000000000000000000..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 0000000000000000000000000000000000000000..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',
     'first-frame-green.gif',
     'first-frame-green.png',
     'first-frame-padding.gif',
     'green.bmp',
     'green.gif',
     'green.ico',
     'green.icon',