Files
FFmpeg/libavcodec
Andreas Rheinhardt 07eb039e04 avcodec/hevc_mp4toannexb_bsf: Check NAL size against available input
The hevc_mp4toannexb bsf does not explicitly check whether a NAL unit
is so big that it extends beyond the end of the input packet; it does so
only implicitly by using the checked version of the bytestream2 API.
But this has downsides compared to real checks: It can lead to huge
allocations (up to 2GiB) even when the input packet is just a few bytes.
And furthermore it leads to uninitialized data being output.
So add a check to error out early if it happens.

Also check directly whether there is enough data for the length field.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit ea1b71e82f)
2020-06-15 04:46:05 +02:00
..
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2020-05-20 03:16:34 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-12-31 16:57:37 -03:00
2019-12-31 16:57:37 -03:00
2019-12-31 16:57:37 -03:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-09-04 20:26:35 +02:00
…
…
…
…
…
…
…
…
…
…
…
2020-05-21 15:32:28 +02:00
…
2020-05-19 17:17:36 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-12-31 19:51:57 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-09-04 20:26:35 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2020-05-19 17:17:36 +02:00
…
…
…
2019-09-02 13:53:08 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2020-05-20 03:24:57 +02:00
…
…
…
…
…
…
2020-05-19 17:17:36 +02:00
…
…
…
…
…
…
…
2020-05-19 17:17:35 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2020-05-19 17:17:35 +02:00
…
…
…
…
2019-09-04 20:26:35 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-12-31 19:51:57 +01:00
…
…
…
…
…
…
…
…
…
…
…
2019-07-08 09:38:03 +02:00
…
…
…
…
…
…
2020-05-20 03:11:21 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
2020-05-20 03:08:52 +02:00
2019-12-31 19:51:56 +01:00
…
…
…
…
2019-12-31 19:51:56 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-12-31 19:51:56 +01:00
…
2019-09-04 20:26:35 +02:00
…
…
2019-09-04 20:26:35 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2019-08-05 19:34:33 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…