diff mbox

[FFmpeg-devel] lavf/mov: Only copy extradata if it exists.

Message ID 201704181059.31700.cehoyos@ag.or.at
State Accepted
Commit c6aaf0840cf9b2b8cb139ed7110d3d47c2bf3d12
Headers show

Commit Message

Carl Eugen Hoyos April 18, 2017, 8:59 a.m. UTC
Hi!

Attached patch fixes an ubsan warning like the following here:
libavformat/mov.c:2332:13: runtime error: null pointer passed as argument 2, 
which is declared to never be null

Please comment, Carl Eugen
From b117fdd2adf3271fcaf8f9388866aaf115284f74 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Tue, 18 Apr 2017 10:56:31 +0200
Subject: [PATCH] lavf/mov: Only copy extradata if it exists.

Avoids undefined call of memcpy(ptr, NULL, 0);
---
 libavformat/mov.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer April 18, 2017, 2:33 p.m. UTC | #1
On Tue, Apr 18, 2017 at 10:59:31AM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes an ubsan warning like the following here:
> libavformat/mov.c:2332:13: runtime error: null pointer passed as argument 2, 
> which is declared to never be null
> 
> Please comment, Carl Eugen

>  mov.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 6e412b49316b5c6529c476233d54723c24b1d740  0001-lavf-mov-Only-copy-extradata-if-it-exists.patch
> From b117fdd2adf3271fcaf8f9388866aaf115284f74 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
> Date: Tue, 18 Apr 2017 10:56:31 +0200
> Subject: [PATCH] lavf/mov: Only copy extradata if it exists.
> 
> Avoids undefined call of memcpy(ptr, NULL, 0);
> ---
>  libavformat/mov.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

thx

[...]
Carl Eugen Hoyos April 19, 2017, 9:40 p.m. UTC | #2
2017-04-18 16:33 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Tue, Apr 18, 2017 at 10:59:31AM +0200, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes an ubsan warning like the following here:
>> libavformat/mov.c:2332:13: runtime error: null pointer passed as argument 2,
>> which is declared to never be null
>>
>> Please comment, Carl Eugen
>
>>  mov.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 6e412b49316b5c6529c476233d54723c24b1d740  0001-lavf-mov-Only-copy-extradata-if-it-exists.patch
>> From b117fdd2adf3271fcaf8f9388866aaf115284f74 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
>> Date: Tue, 18 Apr 2017 10:56:31 +0200
>> Subject: [PATCH] lavf/mov: Only copy extradata if it exists.
>>
>> Avoids undefined call of memcpy(ptr, NULL, 0);
>> ---
>>  libavformat/mov.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> LGTM

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2995a00..03fd90e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2321,7 +2321,7 @@  int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
         } else if (a.size > 0)
             avio_skip(pb, a.size);
 
-        if (sc->extradata) {
+        if (sc->extradata && st->codecpar->extradata) {
             int extra_size = st->codecpar->extradata_size;
 
             /* Move the current stream extradata to the stream context one. */