[FFmpeg-devel] avformat: Fix probing on some JPEGs

Submitted by Nikolas Bowe on Aug. 20, 2019, 1:36 a.m.

Details

Message ID 20190820013648.161805-1-nbowe@google.com
State New
Headers show

Commit Message

Nikolas Bowe Aug. 20, 2019, 1:36 a.m.
Fixes "Invalid data found when processing input" on some JPEGs.

Some large extensionless JPEGs can get probe score collisions.
eg
$ ffprobe -loglevel trace  /tmp/foo
[NULL @ 0x55c130ab04c0] Opening '/tmp/foo' for reading
[file @ 0x55c130ab0f40] Setting default whitelist 'file,crypto'
Probing jpeg_pipe score:6 size:2048
Probing jpeg_pipe score:6 size:4096
Probing jpeg_pipe score:6 size:8192
Probing jpeg_pipe score:6 size:16384
Probing jpeg_pipe score:25 size:32768
Probing jpeg_pipe score:25 size:65536
Probing jpeg_pipe score:25 size:131072
Probing jpeg_pipe score:25 size:262144
Probing jpeg_pipe score:25 size:524288
Probing mpeg score:25 size:1048576
Probing jpeg_pipe score:25 size:1048576
[AVIOContext @ 0x55c130ab9300] Statistics: 1048576 bytes read, 0 seeks
/tmp/foo: Invalid data found when processing input

This patch fixes this by bumping the score in the start-of-scan data.
---
Fixes adsadasda
asd


 libavformat/img2dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Carl Eugen Hoyos Aug. 20, 2019, 1:50 a.m.
Am Di., 20. Aug. 2019 um 03:37 Uhr schrieb Nikolas Bowe
<nbowe-at-google.com@ffmpeg.org>:
>
> Fixes "Invalid data found when processing input" on some JPEGs.
>
> Some large extensionless JPEGs can get probe score collisions.
> eg
> $ ffprobe -loglevel trace  /tmp/foo
> [NULL @ 0x55c130ab04c0] Opening '/tmp/foo' for reading
> [file @ 0x55c130ab0f40] Setting default whitelist 'file,crypto'
> Probing jpeg_pipe score:6 size:2048
> Probing jpeg_pipe score:6 size:4096
> Probing jpeg_pipe score:6 size:8192
> Probing jpeg_pipe score:6 size:16384
> Probing jpeg_pipe score:25 size:32768
> Probing jpeg_pipe score:25 size:65536
> Probing jpeg_pipe score:25 size:131072
> Probing jpeg_pipe score:25 size:262144
> Probing jpeg_pipe score:25 size:524288
> Probing mpeg score:25 size:1048576
> Probing jpeg_pipe score:25 size:1048576
> [AVIOContext @ 0x55c130ab9300] Statistics: 1048576 bytes read, 0 seeks
> /tmp/foo: Invalid data found when processing input
>
> This patch fixes this by bumping the score in the start-of-scan data.
> ---
> Fixes adsadasda
> asd
>
>
>  libavformat/img2dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
> index f8b4a655a5..cb582f97cb 100644
> --- a/libavformat/img2dec.c
> +++ b/libavformat/img2dec.c
> @@ -767,7 +767,7 @@ static int jpeg_probe(const AVProbeData *p)
>      if (state == EOI)
>          return AVPROBE_SCORE_EXTENSION + 1;
>      if (state == SOS)
> -        return AVPROBE_SCORE_EXTENSION / 2;
> +        return AVPROBE_SCORE_EXTENSION / 2 + 1;

This score would mean that mjpeg can never be detected.
I suspect you have to reduce one of the demuxers to "- 1".

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index f8b4a655a5..cb582f97cb 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -767,7 +767,7 @@  static int jpeg_probe(const AVProbeData *p)
     if (state == EOI)
         return AVPROBE_SCORE_EXTENSION + 1;
     if (state == SOS)
-        return AVPROBE_SCORE_EXTENSION / 2;
+        return AVPROBE_SCORE_EXTENSION / 2 + 1;
     return AVPROBE_SCORE_EXTENSION / 8;
 }