[trunk] fixes heap-buffer-overflow in parse_cmdline_encoder
authorAntonin Descampe <antonin@gmail.com>
Tue, 30 Sep 2014 09:48:26 +0000 (09:48 +0000)
committerAntonin Descampe <antonin@gmail.com>
Tue, 30 Sep 2014 09:48:26 +0000 (09:48 +0000)
Fixes issue 403
Thanks Matthieu

src/bin/jp2/opj_compress.c

index db21c5a4d7974355192c0e72b8b98976898250a0..55828b1fa7e15e3b94e576525c05b76b0bf951fe 100644 (file)
@@ -1501,12 +1501,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
     }
 
     /* If subsampled image is provided, automatically disable MCT */
-    if ( ((parameters->decod_format == RAW_DFMT)
-          || (parameters->decod_format == RAWL_DFMT))
-         && ((raw_cp->rawComps[1].dx > 1)
-             || (raw_cp->rawComps[1].dy > 1)
-             || (raw_cp->rawComps[2].dx > 1)
-             || (raw_cp->rawComps[2].dy > 1))) {
+    if ( ((parameters->decod_format == RAW_DFMT) || (parameters->decod_format == RAWL_DFMT))
+         && (   ((raw_cp->rawComp > 1 ) && ((raw_cp->rawComps[1].dx > 1) || (raw_cp->rawComps[1].dy > 1)))
+             || ((raw_cp->rawComp > 2 ) && ((raw_cp->rawComps[2].dx > 1) || (raw_cp->rawComps[2].dy > 1)))
+                                               )) {
         parameters->tcp_mct = 0;
     }