summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_h2645.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-09 23:26:03 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-03-10 20:22:32 +0100
commit66fac1ff7ccbc4fb6a3aa6b9a95de7b6bc31d14e (patch)
treedff0a6b43bc57100cefe94a3cc7f7d9f2c938eca /libavcodec/cbs_h2645.c
parent8f701932b39a6345f2a8bab85f48d555a98802e3 (diff)
avcodec/cbs_h2645: Treat slices without data as invalid
Slices that end after their header (meaning slices after the header without any data before the rbsp_stop_one_bit or possibly without any rbsp_stop_one_bit at all) are invalid and are now dropped. This ensures that one doesn't run into two asserts in cbs_h2645_write_slice_data(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Fixes: 19629/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5676822528524288 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/cbs_h2645.c')
-rw-r--r--libavcodec/cbs_h2645.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 19da58f8fc..7a4eecf439 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -861,6 +861,9 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx,
if (err < 0)
return err;
+ if (!cbs_h2645_read_more_rbsp_data(&gbc))
+ return AVERROR_INVALIDDATA;
+
pos = get_bits_count(&gbc);
len = unit->data_size;
@@ -1036,6 +1039,9 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx,
if (err < 0)
return err;
+ if (!cbs_h2645_read_more_rbsp_data(&gbc))
+ return AVERROR_INVALIDDATA;
+
pos = get_bits_count(&gbc);
len = unit->data_size;