aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/nuv.c
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2012-08-06 13:59:04 +0200
committerJanne Grunau <janne-libav@jannau.net>2012-08-06 14:34:12 +0200
commit859a579e9bbf47fae2e09494c43bcf813dcb2fad (patch)
treed1115299d70ddfaf865e3d275e7c2b179dd59d29 /libavcodec/nuv.c
parent110d015ad450ea1b2fd40f0e9ce1c53507cdec5d (diff)
downloadffmpeg-859a579e9bbf47fae2e09494c43bcf813dcb2fad.tar.gz
nuv: check RTjpeg header for validity
CC: libav-stable@libav.org
Diffstat (limited to 'libavcodec/nuv.c')
-rw-r--r--libavcodec/nuv.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index 2e01602db7..4cb9b951a1 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -184,17 +184,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
if (c->codec_frameheader) {
int w, h, q;
- if (buf_size < 12) {
+ if (buf_size < RTJPEG_HEADER_SIZE || buf[4] != RTJPEG_HEADER_SIZE ||
+ buf[5] != RTJPEG_FILE_VERSION) {
av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
w = AV_RL16(&buf[6]);
h = AV_RL16(&buf[8]);
q = buf[10];
if (!codec_reinit(avctx, w, h, q))
return -1;
- buf = &buf[12];
- buf_size -= 12;
+ buf = &buf[RTJPEG_HEADER_SIZE];
+ buf_size -= RTJPEG_HEADER_SIZE;
}
if (keyframe && c->pic.data[0])