diff mbox

[FFmpeg-devel] avformat/rawenc: avoid divide by 0 when writing adx trailer

Message ID 20190713205037.17633-1-andriy.gelman@gmail.com
State Withdrawn
Headers show

Commit Message

Andriy Gelman July 13, 2019, 8:50 p.m. UTC
From: Andriy Gelman <andriy.gelman@gmail.com>

Fixes #7985
This patch checks that the number of audio channels is not zero when
writing the total sample count in adx header.
---
 libavformat/rawenc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Carl Eugen Hoyos July 13, 2019, 10:40 p.m. UTC | #1
> Am 13.07.2019 um 22:50 schrieb Andriy Gelman <andriy.gelman@gmail.com>:
> 
> From: Andriy Gelman <andriy.gelman@gmail.com>
> 
> Fixes #7985

Did you check the patch mentioned there?

Carl Eugen
Andriy Gelman July 14, 2019, 3:10 a.m. UTC | #2
On Sun, 14. Jul 00:40, Carl Eugen Hoyos wrote:
> 
> > Am 13.07.2019 um 22:50 schrieb Andriy Gelman <andriy.gelman@gmail.com>:
> > 
> > From: Andriy Gelman <andriy.gelman@gmail.com>
> > 
> > Fixes #7985
> 
> Did you check the patch mentioned there?

Sorry, I missed that you sent a patch. 

I applied it, but get a divide by 0 exception in libavformat/rawenc.c:60
because par->channels = 0 with the example in #7985 

Andriy
Andriy Gelman July 14, 2019, 4:12 a.m. UTC | #3
On Sat, 13. Jul 23:10, Andriy Gelman wrote:
> On Sun, 14. Jul 00:40, Carl Eugen Hoyos wrote:
> > 
> > > Am 13.07.2019 um 22:50 schrieb Andriy Gelman <andriy.gelman@gmail.com>:
> > > 
> > > From: Andriy Gelman <andriy.gelman@gmail.com>
> > > 
> > > Fixes #7985
> > 
> > Did you check the patch mentioned there?
> 
> Sorry, I missed that you sent a patch. 
> 
> I applied it, but get a divide by 0 exception in libavformat/rawenc.c:60
> because par->channels = 0 with the example in #7985 

ok, I think a different patch you sent for #7979 will also solve
the above problem
https://patchwork.ffmpeg.org/patch/13780/

Andriy
diff mbox

Patch

diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 993d232b70..bf8537fffb 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -65,6 +65,9 @@  static int adx_write_trailer(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     AVCodecParameters *par = s->streams[0]->codecpar;
 
+    if (par->channels == 0)
+      return AVERROR_INVALIDDATA;
+
     if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
         int64_t file_size = avio_tell(pb);
         uint64_t sample_count = (file_size - 36) / par->channels / 18 * 32;