76f8c5
From 89a5367d49b2556a2635dbb6d48d6a6b182a2c6c Mon Sep 17 00:00:00 2001
76f8c5
From: Albert Astals Cid <aacid@kde.org>
76f8c5
Date: Thu, 23 May 2019 00:54:29 +0200
76f8c5
Subject: [PATCH] JPEG2000Stream: fail gracefully if not all components have
76f8c5
 the same WxH
76f8c5
76f8c5
I think this is just a mistake, or at least the only file we have with
76f8c5
this scenario is a fuzzed one
76f8c5
---
76f8c5
 poppler/JPEG2000Stream.cc | 8 +++++++-
76f8c5
 1 file changed, 7 insertions(+), 1 deletion(-)
76f8c5
76f8c5
diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc
76f8c5
index 15bbcae4..0eea3a2d 100644
76f8c5
--- a/poppler/JPEG2000Stream.cc
76f8c5
+++ b/poppler/JPEG2000Stream.cc
76f8c5
@@ -4,7 +4,7 @@
76f8c5
 //
76f8c5
 // A JPX stream decoder using OpenJPEG
76f8c5
 //
76f8c5
-// Copyright 2008-2010, 2012 Albert Astals Cid <aacid@kde.org>
76f8c5
+// Copyright 2008-2010, 2012, 2019 Albert Astals Cid <aacid@kde.org>
76f8c5
 // Copyright 2011 Daniel Glöckner <daniel-gl@gmx.net>
76f8c5
 // Copyright 2013 Adrian Johnson <ajohnson@redneon.com>
76f8c5
 //
76f8c5
@@ -253,6 +253,12 @@ void JPXStream::init()
76f8c5
         close();
76f8c5
         break;
76f8c5
       }
76f8c5
+      const int componentPixels = image->comps[component].w * image->comps[component].h;
76f8c5
+      if (componentPixels != npixels) {
76f8c5
+        error(errSyntaxWarning, -1, "Component {0:d} has different WxH than component 0", component);
76f8c5
+        close();
76f8c5
+        break;
76f8c5
+      }
76f8c5
       unsigned char *cdata = (unsigned char *)image->comps[component].data;
76f8c5
       int adjust = 0;
76f8c5
       if (image->comps[component].prec > 8)
76f8c5
-- 
76f8c5
2.21.0
76f8c5