Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame^] | 1 | CVE: CVE-2021-38171 |
| 2 | Upstream-Status: Backport |
| 3 | Signed-off-by: Kiran Surendran <kiran.surendran@windriver.com> |
| 4 | |
| 5 | From fb993619d1035fa9646506925ea70fb122038999 Mon Sep 17 00:00:00 2001 |
| 6 | From: maryam ebrahimzadeh <me22bee@outlook.com> |
| 7 | Date: Wed, 4 Aug 2021 16:15:18 -0400 |
| 8 | Subject: [PATCH] avformat/adtsenc: return value check for init_get_bits in |
| 9 | adts_decode_extradata |
| 10 | |
| 11 | As the second argument for init_get_bits (buf) can be crafted, a return value check for this function call is necessary. |
| 12 | 'buf' is part of 'AVPacket pkt'. |
| 13 | replace init_get_bits with init_get_bits8. |
| 14 | |
| 15 | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> |
| 16 | (cherry picked from commit 9ffa49496d1aae4cbbb387aac28a9e061a6ab0a6) |
| 17 | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> |
| 18 | --- |
| 19 | libavformat/adtsenc.c | 6 ++++-- |
| 20 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 21 | |
| 22 | diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c |
| 23 | index 3595cb3bb2..c35a12a628 100644 |
| 24 | --- a/libavformat/adtsenc.c |
| 25 | +++ b/libavformat/adtsenc.c |
| 26 | @@ -51,9 +51,11 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui |
| 27 | GetBitContext gb; |
| 28 | PutBitContext pb; |
| 29 | MPEG4AudioConfig m4ac; |
| 30 | - int off; |
| 31 | + int off, ret; |
| 32 | |
| 33 | - init_get_bits(&gb, buf, size * 8); |
| 34 | + ret = init_get_bits8(&gb, buf, size); |
| 35 | + if (ret < 0) |
| 36 | + return ret; |
| 37 | off = avpriv_mpeg4audio_get_config2(&m4ac, buf, size, 1, s); |
| 38 | if (off < 0) |
| 39 | return off; |
| 40 | -- |
| 41 | 2.31.1 |
| 42 | |