[FFmpeg-devel] [PATCH 1/2] wmavoice: truncate spillover_nbits if too large

Ronald S. Bultje rsbultje at gmail.com
Mon Jan 2 00:27:54 EET 2017


Hi,

On Sun, Jan 1, 2017 at 5:18 PM, Andreas Cadhalpun <
andreas.cadhalpun at googlemail.com> wrote:

> This fixes triggering the av_assert0(ret <= tmp.size).
>
> The problem was reintroduced by commit
> 7b27dd5c16de785297ce4de4b88afa0b6685f61d and originally fixed by
> 2a4700a4f03280fa8ba4fc0f8a9987bb550f0d1e.
>
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  libavcodec/wmavoice.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
> index cd5958c7bc..1bfad46b2e 100644
> --- a/libavcodec/wmavoice.c
> +++ b/libavcodec/wmavoice.c
> @@ -1923,6 +1923,11 @@ static int wmavoice_decode_packet(AVCodecContext
> *ctx, void *data,
>           * continuing to parse new superframes in the current packet. */
>          if (s->sframe_cache_size > 0) {
>              int cnt = get_bits_count(gb);
> +            if (cnt + s->spillover_nbits > avpkt->size * 8) {
> +                av_log(ctx, AV_LOG_WARNING, "Number of spillover bits %d
> larger than remaining packet size %d, truncating.\n",
> +                       s->spillover_nbits, avpkt->size * 8 - cnt);
> +                s->spillover_nbits = avpkt->size * 8 - cnt;
> +            }


This litters stderr uselessly. It doesn't help a user or developer
accomplish anything. Let me explain, because this is probably confusing.

If a library integrator (e.g., the developer of gst-ffmpeg) is playing with
wmavoice and forgets to set block_align, the codec should error out.
Ideally, it does this saying block_align is zero, so the developer knows
what to do. But this is not strictly required and we typically don't do
this.

However, the above can only happen during corrupt streams (or fuzzing). The
user cannot fix this. So any detailed error is useless. Therefore, we
should not display any detailed error (or warning) message.

Ronald


More information about the ffmpeg-devel mailing list