Commit e55e0994 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '7b588bb6'

* commit '7b588bb6':
  svq1: do not modify the input packet
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents c6286279 7b588bb6
...@@ -60,6 +60,10 @@ typedef struct SVQ1Context { ...@@ -60,6 +60,10 @@ typedef struct SVQ1Context {
HpelDSPContext hdsp; HpelDSPContext hdsp;
GetBitContext gb; GetBitContext gb;
AVFrame *prev; AVFrame *prev;
uint8_t *pkt_swapped;
int pkt_swapped_allocated;
int width; int width;
int height; int height;
int frame_code; int frame_code;
...@@ -624,7 +628,24 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data, ...@@ -624,7 +628,24 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data,
/* swap some header bytes (why?) */ /* swap some header bytes (why?) */
if (s->frame_code != 0x20) { if (s->frame_code != 0x20) {
uint32_t *src = (uint32_t *)(buf + 4); uint32_t *src;
if (buf_size < 9 * 4) {
av_log(avctx, AV_LOG_ERROR, "Input packet too small\n");
return AVERROR_INVALIDDATA;
}
av_fast_malloc(s->pkt_swapped, &s->pkt_swapped_allocated,
buf_size);
if (!s->pkt_swapped)
return AVERROR(ENOMEM);
memcpy(s->pkt_swapped, buf, buf_size);
buf = s->pkt_swapped;
init_get_bits(&s->gb, buf, buf_size * 8);
skip_bits(&s->gb, 22);
src = (uint32_t *)(s->pkt_swapped + 4);
if (buf_size < 36) if (buf_size < 36)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -796,6 +817,7 @@ static av_cold int svq1_decode_end(AVCodecContext *avctx) ...@@ -796,6 +817,7 @@ static av_cold int svq1_decode_end(AVCodecContext *avctx)
SVQ1Context *s = avctx->priv_data; SVQ1Context *s = avctx->priv_data;
av_frame_free(&s->prev); av_frame_free(&s->prev);
av_freep(&s->pkt_swapped);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment