From 41ee973034e8dba9f404ff9a609bba912b213db2 Mon Sep 17 00:00:00 2001
From: maryam ebrahimzadeh <me22bee@outlook.com>
Date: Tue, 2 Jul 2024 15:28:58 +0800
Subject: [PATCH] CVE-2021-38171

---
 libavformat/adtsenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 3c2840c..3807d67 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -50,9 +50,11 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui
     GetBitContext gb;
     PutBitContext pb;
     MPEG4AudioConfig m4ac;
-    int off;
+    int off, ret;
 
-    init_get_bits(&gb, buf, size * 8);
+    ret = init_get_bits8(&gb, buf, size);
+    if (ret < 0)
+        return ret;
     off = avpriv_mpeg4audio_get_config(&m4ac, buf, size * 8, 1);
     if (off < 0)
         return off;
-- 
2.43.0

