openjpeg2/SOURCES/openjpeg2_CVE-2018-18088.patch

45 lines
1.3 KiB
Diff

From 3290295708fddcef482eb453432dc34bf4b54b19 Mon Sep 17 00:00:00 2001
From: szukw000 <szukw000@arcor.de>
Date: Fri, 12 Oct 2018 13:41:36 +0200
Subject: [PATCH] Change in pnmtoimage if image->comps[].data is NULL
---
src/bin/jp2/convert.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index 7040969..0b17602 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -1998,7 +1998,7 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
int *red, *green, *blue, *alpha;
int wr, hr, max;
int i;
- unsigned int compno, ncomp;
+ unsigned int compno, ncomp, ui;
int adjustR, adjustG, adjustB, adjustA;
int fails, two, want_gray, has_alpha, triple;
int prec, v;
@@ -2006,6 +2006,18 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
const char *tmp = outfile;
char *destname;
+ fails = 0;
+ ncomp = image->numcomps;
+ for(ui = 0; ui < ncomp; ++ui) {
+ if(image->comps[ui].data == NULL) {
+ fprintf(stderr, "imagetopnm data[%u] == NULL\n", ui);
+ fails = 1;
+ }
+ }
+ if(fails) {
+ return 1;
+ }
+
alpha = NULL;
if ((prec = (int)image->comps[0].prec) > 16) {
--
2.17.2