summaryrefslogtreecommitdiff
path: root/libavcodec/jpeg2000dec.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2017-12-27 23:18:58 +0100
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2017-12-28 02:58:56 +0100
commit658bdc67715b3fbf75f92c7a459272149e3859df (patch)
tree7382a06523d7a07880d7df33d3118a6870113088 /libavcodec/jpeg2000dec.c
parentad73b32d2922f4237405043d19763229aee0e59e (diff)
downloadffmpeg-658bdc67715b3fbf75f92c7a459272149e3859df.tar.gz
lavc/jpeg2000dec: Support reading 64-bit atom size.
Fixes ticket #6935.
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r--libavcodec/jpeg2000dec.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 8071dc3c84..01fe4b3949 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -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;