lavc/jpeg2000dec: Support reading 64-bit atom size.
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>
Wed, 27 Dec 2017 22:18:58 +0000 (23:18 +0100)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Thu, 28 Dec 2017 01:58:56 +0000 (02:58 +0100)
Fixes ticket #6935.

libavcodec/jpeg2000dec.c

index 8071dc3..01fe4b3 100644 (file)
@@ -2009,7 +2009,16 @@ static int jp2_find_codestream(Jpeg2000DecoderContext *s)
            bytestream2_get_bytes_left(&s->g) >= 8) {
         atom_size = bytestream2_get_be32u(&s->g);
         atom      = bytestream2_get_be32u(&s->g);
-        atom_end  = bytestream2_tell(&s->g) + atom_size - 8;
+        if (atom_size == 1) {
+            if (bytestream2_get_be32u(&s->g)) {
+                avpriv_request_sample(s->avctx, "Huge atom");
+                return 0;
+            }
+            atom_size = bytestream2_get_be32u(&s->g);
+            atom_end  = bytestream2_tell(&s->g) + atom_size - 16;
+        } else {
+            atom_end  = bytestream2_tell(&s->g) + atom_size -  8;
+        }
 
         if (atom == JP2_CODESTREAM)
             return 1;