diff mbox series

[FFmpeg-devel,v4,1/2] libavcodec/jpeg2000dec: Fix codeblock decode check

Message ID 20200723171111.11312-1-gautamramk@gmail.com
State Accepted
Commit ff5b9ece4290d245ba3bbf110d90f3f432dda3cc
Headers show
Series [FFmpeg-devel,v4,1/2] libavcodec/jpeg2000dec: Fix codeblock decode check | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Gautam Ramakrishnan July 23, 2020, 5:11 p.m. UTC
From: Gautam Ramakrishnan <gautamramk@gmail.com>

The codeblock decoder checks whether the mqc decoder
has decoded the right number of bytes. However, this
check does not account for the fact that the mqc encoder's
flush routine adds 2 bytes of data which does not have to be
read by the decoder. The check is modified to account for
this. This patch solves issue #4827
---
 libavcodec/jpeg2000dec.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer July 24, 2020, 7:40 p.m. UTC | #1
On Thu, Jul 23, 2020 at 10:41:10PM +0530, gautamramk@gmail.com wrote:
> From: Gautam Ramakrishnan <gautamramk@gmail.com>
> 
> The codeblock decoder checks whether the mqc decoder
> has decoded the right number of bytes. However, this
> check does not account for the fact that the mqc encoder's
> flush routine adds 2 bytes of data which does not have to be
> read by the decoder. The check is modified to account for
> this. This patch solves issue #4827
> ---
>  libavcodec/jpeg2000dec.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index e941ebb5d0..a470cf47da 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1754,9 +1754,13 @@  static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
         pass_cnt ++;
     }
 
-    if (cblk->data + cblk->length - 2*(term_cnt < cblk->nb_terminations) != t1->mqc.bp) {
+    if (cblk->data + cblk->length - 2 > t1->mqc.bp) {
         av_log(s->avctx, AV_LOG_WARNING, "End mismatch %"PTRDIFF_SPECIFIER"\n",
-               cblk->data + cblk->length - 2*(term_cnt < cblk->nb_terminations) - t1->mqc.bp);
+               cblk->data + cblk->length - 2 - t1->mqc.bp);
+    }
+
+    if (cblk->data + cblk->length < t1->mqc.bp) {
+        av_log(s->avctx, AV_LOG_WARNING, "Synthetic End of Stream Marker Read.\n");
     }
 
     return 1;