diff mbox

[FFmpeg-devel] lavc/mjpegdec: Only read JFIF thumbnail size if the segment is long enough.

Message ID 201608290012.34861.cehoyos@ag.or.at
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Aug. 28, 2016, 10:12 p.m. UTC
Hi!

Attached patch fixes ticket #5805.

Please comment, Carl Eugen
From 215d45b2226cb5681be09bb4e0a2c135925ed6f5 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Mon, 29 Aug 2016 00:09:06 +0200
Subject: [PATCH] lavc/mjpegdec: Only read JFIF thumbnail size if the segment
 is long enough.

Fixes ticket #5805.
---
 libavcodec/mjpegdec.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 29, 2016, 10:59 a.m. UTC | #1
On Mon, Aug 29, 2016 at 12:12:34AM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #5805.
> 
> Please comment, Carl Eugen

>  mjpegdec.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 4ccdddc80ba0dbd460f9d7ecb046cad73d50ea51  0001-lavc-mjpegdec-Only-read-JFIF-thumbnail-size-if-the-s.patch
> From 215d45b2226cb5681be09bb4e0a2c135925ed6f5 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
> Date: Mon, 29 Aug 2016 00:09:06 +0200
> Subject: [PATCH] lavc/mjpegdec: Only read JFIF thumbnail size if the segment
>  is long enough.
> 
> Fixes ticket #5805.

LGTM,

can you add a fate test for this ?

thx

[...]
Carl Eugen Hoyos Sept. 3, 2016, 12:26 p.m. UTC | #2
2016-08-29 12:59 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Mon, Aug 29, 2016 at 12:12:34AM +0200, Carl Eugen Hoyos wrote:

>> Fixes ticket #5805.
>
> LGTM,

Patch applied.

> can you add a fate test for this ?

Please upload the sample to fate-suite/jpg/.

Thank you, Carl Eugen
Michael Niedermayer Sept. 3, 2016, 5:58 p.m. UTC | #3
On Sat, Sep 03, 2016 at 02:26:36PM +0200, Carl Eugen Hoyos wrote:
> 2016-08-29 12:59 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> > On Mon, Aug 29, 2016 at 12:12:34AM +0200, Carl Eugen Hoyos wrote:
> 
> >> Fixes ticket #5805.
> >
> > LGTM,
> 
> Patch applied.
> 
> > can you add a fate test for this ?
> 
> Please upload the sample to fate-suite/jpg/.

uploaded

thx

[...]
Carl Eugen Hoyos Sept. 3, 2016, 10:37 p.m. UTC | #4
2016-09-03 19:58 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
>> > can you add a fate test for this ?
>>
>> Please upload the sample to fate-suite/jpg/.
>
> uploaded

Patch sent.

Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 633a8f0..515d2f8 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1690,6 +1690,8 @@  static int mjpeg_decode_app(MJpegDecodeContext *s)
                    s->avctx->sample_aspect_ratio.num,
                    s->avctx->sample_aspect_ratio.den);
 
+        len -= 8;
+        if (len >= 2) {
         t_w = get_bits(&s->gb, 8);
         t_h = get_bits(&s->gb, 8);
         if (t_w && t_h) {
@@ -1697,7 +1699,8 @@  static int mjpeg_decode_app(MJpegDecodeContext *s)
             if (len -10 - (t_w * t_h * 3) > 0)
                 len -= t_w * t_h * 3;
         }
-        len -= 10;
+        len -= 2;
+        }
         goto out;
     }