Quoting Hendrik Leppkes (2015-03-24 09:14:20)
> On Tue, Mar 24, 2015 at 7:35 AM, Anton Khirnov <[email protected]> wrote:
> > Quoting Hendrik Leppkes (2015-03-23 12:45:19)
> >> diff --git a/libavcodec/libdcadec.c b/libavcodec/libdcadec.c
> >> new file mode 100644
> >> index 0000000..7ca8942
> >> --- /dev/null
> >> +++ b/libavcodec/libdcadec.c
> >> @@ -0,0 +1,197 @@
> >> +/*
> >> + * libdcadec decoder wrapper
> >> + * Copyright (C) 2015 Hendrik Leppkes
> >> + *
> >> + * This file is part of FFmpeg.
> >> + *
> >> + * FFmpeg is free software; you can redistribute it and/or
> >> + * modify it under the terms of the GNU Lesser General Public
> >> + * License as published by the Free Software Foundation; either
> >> + * version 2.1 of the License, or (at your option) any later version.
> >> + *
> >> + * FFmpeg is distributed in the hope that it will be useful,
> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> + * Lesser General Public License for more details.
> >> + *
> >> + * You should have received a copy of the GNU Lesser General Public
> >> + * License along with FFmpeg; if not, write to the Free Software
> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
> >> 02110-1301 USA
> >> + */
> >> +
> >> +#include <libdcadec/dca_context.h>
> >> +
> >> +#include "libavutil/avassert.h"
> >> +#include "libavutil/channel_layout.h"
> >> +#include "libavutil/common.h"
> >> +#include "libavutil/opt.h"
> >> +#include "avcodec.h"
> >> +#include "dca.h"
> >> +#include "dca_syncwords.h"
> >> +#include "internal.h"
> >> +
> >> +typedef struct DCADecContext {
> >> +    struct dcadec_context *ctx;
> >> +    uint8_t *buffer;
> >> +    int buffer_size;
> >> +} DCADecContext;
> >> +
> >> +static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
> >> +                               int *got_frame_ptr, AVPacket *avpkt)
> >> +{
> >> +    DCADecContext *s = avctx->priv_data;
> >> +    AVFrame *frame = data;
> >> +    int ret, i, k;
> >> +    int **samples, nsamples, channel_mask, sample_rate, bits_per_sample, 
> >> profile;
> >> +    uint32_t mrk;
> >> +    uint8_t *input = avpkt->data;
> >> +    int input_size = avpkt->size;
> >> +
> >> +    /* convert bytestream syntax to RAW BE format if required */
> >> +    mrk = AV_RB32(input);
> >
> > This read should be checked. The packet size can be anything positive.
> 
> As far as I know, decoders can rely on input packets being padded to
> at least FF_INPUT_BUFFER_PADDING_SIZE, so this read is safe.
> Other decoders do the same thing, ie. the native dca decoder. :p
> 

I'd still feel better if we stopped relying on this in new code.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to