[trunk] added box length inconsistency check
authorAntonin Descampe <antonin@gmail.com>
Mon, 6 Oct 2014 21:05:27 +0000 (21:05 +0000)
committerAntonin Descampe <antonin@gmail.com>
Mon, 6 Oct 2014 21:05:27 +0000 (21:05 +0000)
Update issue 364

issue364-38.patch applied. Thanks Matthieu.

src/lib/openjp2/jp2.c

index d408d8e4a9c92f4e475af89d68fbe997d237f582..c77bfaaef8fd7792fb5095149bd09c49b26e8ff8 100644 (file)
@@ -2282,7 +2282,10 @@ OPJ_BOOL opj_jp2_read_boxhdr_char(   opj_jp2_box_t *box,
                opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
                return OPJ_FALSE;
        }
-
+       if (box->length < *p_number_bytes_read) {
+               opj_event_msg(p_manager, EVT_ERROR, "Box length is inconsistent.\n");
+               return OPJ_FALSE;
+       }
        return OPJ_TRUE;
 }