diff mbox series

[FFmpeg-devel,1/5] avcodec/h265_metadata_bsf: Check nb_units before accessing the first in h265_metadata_update_fragment()

Message ID 20210330113129.14852-1-michael@niedermayer.cc
State Accepted
Commit 497ea04dbda78d4eb9cffd208737b676f838725c
Headers show
Series [FFmpeg-devel,1/5] avcodec/h265_metadata_bsf: Check nb_units before accessing the first in h265_metadata_update_fragment() | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer March 30, 2021, 11:31 a.m. UTC
Fixes: null pointer dereference
Fixes: 32113/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-4803262287052800

Same as 0c48c332eeb2866d9353125f701e099c48889463

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/h265_metadata_bsf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer April 1, 2021, 8:02 a.m. UTC | #1
On Tue, Mar 30, 2021 at 01:31:25PM +0200, Michael Niedermayer wrote:
> Fixes: null pointer dereference
> Fixes: 32113/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-4803262287052800
> 
> Same as 0c48c332eeb2866d9353125f701e099c48889463
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/h265_metadata_bsf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply patchset

[...]
diff mbox series

Patch

diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index 59325c0471..d841839762 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -335,7 +335,7 @@  static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
     int err, i;
 
     // If an AUD is present, it must be the first NAL unit.
-    if (au->units[0].type == HEVC_NAL_AUD) {
+    if (au->nb_units && au->units[0].type == HEVC_NAL_AUD) {
         if (ctx->aud == BSF_ELEMENT_REMOVE)
             ff_cbs_delete_unit(au, 0);
     } else {