]> git.sesse.net Git - ffmpeg/commit
avcodec/hevc_mp4toannexb_bsf: Check NAL size against available input
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 27 May 2020 17:09:14 +0000 (19:09 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 15 Jun 2020 01:18:11 +0000 (03:18 +0200)
commitea1b71e82f5a1752d59d3bfb9704092a79eba6b5
treeabe886b69eacd52dfa5fcbcdf5af46bd60c606cf
parent4b3b217e3074687f2b55a1dfb3e6942c9f261908
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>
libavcodec/hevc_mp4toannexb_bsf.c