jp2: convert: fix null pointer dereference 1160/head
authorHugo Lefeuvre <hle@debian.org>
Wed, 7 Nov 2018 17:48:29 +0000 (18:48 +0100)
committerHugo Lefeuvre <hle@debian.org>
Wed, 7 Nov 2018 17:53:18 +0000 (18:53 +0100)
Tile components in a JP2 image might have null data pointer by defining a
zero component size (for example using large horizontal or vertical
sampling periods). This null data pointer leads to null image component
data pointer, causing crash when dereferenced without != null check in
imagetopnm.

Add != null check.

This commit addresses #1152 (CVE-2018-18088).

src/bin/jp2/convert.c

index fa02e31c5a458a7d1a7e41b231756bc82d20ad0e..e670cd82fbe710107f4ee46697bdb3b5a13e38bf 100644 (file)
@@ -2233,6 +2233,11 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
                 opj_version(), wr, hr, max);
 
         red = image->comps[compno].data;
+        if (!red) {
+            fclose(fdest);
+            continue;
+        }
+
         adjustR =
             (image->comps[compno].sgnd ? 1 << (image->comps[compno].prec - 1) : 0);