summaryrefslogtreecommitdiff
path: root/libavcodec/bethsoftvideo.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-11-21 21:22:44 +0100
committerAnton Khirnov <anton@khirnov.net>2011-11-23 21:58:30 +0100
commit3eedd29bd7df6f21a79e1a67a6d905049996d2ec (patch)
tree273e4fed22ac128f6643dec841691ff37e118611 /libavcodec/bethsoftvideo.c
parent5872c781222d5f61b69a511ea6b024d4cab0aaf6 (diff)
bethsoftvideo: return proper consumed size for palette packets.
Also check for sufficient packet size.
Diffstat (limited to 'libavcodec/bethsoftvideo.c')
-rw-r--r--libavcodec/bethsoftvideo.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c
index bd21dbff63..f4020d6ee5 100644
--- a/libavcodec/bethsoftvideo.c
+++ b/libavcodec/bethsoftvideo.c
@@ -46,14 +46,19 @@ static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx)
return 0;
}
-static void set_palette(AVFrame * frame, const uint8_t * palette_buffer)
+static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)
{
uint32_t * palette = (uint32_t *)frame->data[1];
int a;
+
+ if (buf_size < 256*3)
+ return AVERROR_INVALIDDATA;
+
for(a = 0; a < 256; a++){
palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
}
frame->palette_has_changed = 1;
+ return 256*3;
}
static int bethsoftvid_decode_frame(AVCodecContext *avctx,
@@ -80,8 +85,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
switch(block_type = *buf++){
case PALETTE_BLOCK:
- set_palette(&vid->frame, buf);
- return 0;
+ return set_palette(&vid->frame, buf, buf_size);
case VIDEO_YOFF_P_FRAME:
yoffset = bytestream_get_le16(&buf);
if(yoffset >= avctx->height)