]> granicus.if.org Git - openjpeg/commitdiff
[trunk] add a check on Zppm value in PPM markers (fixes issue 393)
authorAntonin Descampe <antonin@gmail.com>
Tue, 21 Oct 2014 12:27:58 +0000 (12:27 +0000)
committerAntonin Descampe <antonin@gmail.com>
Tue, 21 Oct 2014 12:27:58 +0000 (12:27 +0000)
src/lib/openjp2/j2k.c

index af8d5316d9677a4e69e41d41932b2b94338b71af..6acd3ec58b4ce7b3578efe476a3986ff562c28f7 100644 (file)
@@ -3554,6 +3554,14 @@ OPJ_BOOL j2k_read_ppm_v3 (
 
         /* First PPM marker */
         if (l_Z_ppm == 0) {
+                if (l_cp->ppm_data != NULL) {
+                        opj_event_msg(p_manager, EVT_ERROR, "Zppm O already processed. Found twice.\n");
+                        opj_free(l_cp->ppm_data);
+                        l_cp->ppm_data = NULL;
+                        l_cp->ppm_buffer = NULL;
+                        l_cp->ppm = 0; /* do not use PPM */
+                        return OPJ_FALSE;
+                }
                 /* We need now at least the Nppm^0 element */
                 if (p_header_size < 4) {
                         opj_event_msg(p_manager, EVT_ERROR, "Error reading PPM marker\n");