diff mbox

[FFmpeg-devel,7/7] avcodec/cbs_mpeg2: Treat slices without data as invalid

Message ID 20191209222604.28920-7-andreas.rheinhardt@gmail.com
State Accepted
Headers show

Commit Message

Andreas Rheinhardt Dec. 9, 2019, 10:26 p.m. UTC
They are spec-incompliant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/cbs_mpeg2.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Michael Niedermayer Feb. 9, 2020, 9:14 p.m. UTC | #1
On Mon, Dec 09, 2019 at 11:26:04PM +0100, Andreas Rheinhardt wrote:
> They are spec-incompliant.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/cbs_mpeg2.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index e42c602476..b57551c92a 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -245,6 +245,9 @@  static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx,
         if (err < 0)
             return err;
 
+        if (!get_bits_left(&gbc))
+            return AVERROR_INVALIDDATA;
+
         pos = get_bits_count(&gbc);
         len = unit->data_size;