summaryrefslogtreecommitdiffstats
path: root/contrib/ffmpeg/A19-matroskaenc-aac-extradata.patch
blob: 73a406292c498f08458b3b98187752b5fd89b2bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From a3fa88bdfd6c9615ea9b9f64caf722fa2292d29a Mon Sep 17 00:00:00 2001
From: John Stebbins <jstebbins@jetheaddev.com>
Date: Sat, 2 May 2020 07:26:29 -0600
Subject: [PATCH] avformat/matroskaenc: return error if aac extradata changes

extradata changing would result in an invalid stream.
also, as the code was written, rewriting extradata was corrupting the
track header resulting in an invalid file.

(cherry picked from commit 805890cddee93ebafcf6db8784315aa3fd6faf81)
---
 libavformat/matroskaenc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index cef504fa05..ea7f81ab94 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2283,6 +2283,14 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
         if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
             int filler, output_sample_rate = 0;
             int64_t curpos;
+            if (par->extradata && par->extradata_size)
+                if (par->extradata_size != side_data_size ||
+                    memcmp(par->extradata, side_data, side_data_size)) {
+                    av_log(s, AV_LOG_ERROR, "Error, AAC extradata changed mid-stream.\n");
+                    return AVERROR(EINVAL);
+                } else // Already written
+                    break;
+
             ret = get_aac_sample_rates(s, side_data, side_data_size, &track->sample_rate,
                                        &output_sample_rate);
             if (ret < 0)
-- 
2.25.4