diff mbox

[FFmpeg-devel,2/4] avformat/vividas: Check av_xiphlacing() return value before use

Message ID 20190821221855.1844-2-michael@niedermayer.cc
State Accepted
Commit 5937f0550304e39be64ce41cc936634f1db54e5d
Headers show

Commit Message

Michael Niedermayer Aug. 21, 2019, 10:18 p.m. UTC
Fixes: out of array access
Fixes: 16277/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5696629440512000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/vividas.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Aug. 22, 2019, 7:44 a.m. UTC | #1
probably ok

On Thu, Aug 22, 2019 at 12:21 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> Fixes: out of array access
> Fixes:
> 16277/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5696629440512000
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> <https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by>:
> Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/vividas.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/vividas.c b/libavformat/vividas.c
> index 0c33ca2da8..645e322b6e 100644
> --- a/libavformat/vividas.c
> +++ b/libavformat/vividas.c
> @@ -392,8 +392,14 @@ static int track_header(VividasDemuxContext *viv,
> AVFormatContext *s,  uint8_t *
>              p = st->codecpar->extradata;
>              p[0] = 2;
>
> -            for (j = 0; j < num_data - 1; j++)
> -                offset += av_xiphlacing(&p[offset], data_len[j]);
> +            for (j = 0; j < num_data - 1; j++) {
> +                unsigned delta = av_xiphlacing(&p[offset], data_len[j]);
> +                if (delta > data_len[j]) {
> +                    av_free(pb);
> +                    return AVERROR_INVALIDDATA;
> +                }
> +                offset += delta;
> +            }
>
>              for (j = 0; j < num_data; j++) {
>                  int ret = avio_read(pb, &p[offset], data_len[j]);
> --
> 2.23.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Aug. 22, 2019, 3:57 p.m. UTC | #2
On Thu, Aug 22, 2019 at 09:44:02AM +0200, Paul B Mahol wrote:
> probably ok

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index 0c33ca2da8..645e322b6e 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -392,8 +392,14 @@  static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
             p = st->codecpar->extradata;
             p[0] = 2;
 
-            for (j = 0; j < num_data - 1; j++)
-                offset += av_xiphlacing(&p[offset], data_len[j]);
+            for (j = 0; j < num_data - 1; j++) {
+                unsigned delta = av_xiphlacing(&p[offset], data_len[j]);
+                if (delta > data_len[j]) {
+                    av_free(pb);
+                    return AVERROR_INVALIDDATA;
+                }
+                offset += delta;
+            }
 
             for (j = 0; j < num_data; j++) {
                 int ret = avio_read(pb, &p[offset], data_len[j]);