aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-05 03:52:49 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-05 03:54:50 +0200
commit7fc9c7c35b1796040d4b8e11c5055cc820f79615 (patch)
treedd5d2d2f0d39557e6e4bd27a768f59cd53386880
parent3ef8b4322cba2ebf9fd6b1c15d068ee90e9f9f96 (diff)
parenta1f7844a11010d8552c75424d1a831b37a0ae5d9 (diff)
downloadffmpeg-7fc9c7c35b1796040d4b8e11c5055cc820f79615.tar.gz
Merge commit 'a1f7844a11010d8552c75424d1a831b37a0ae5d9' into release/2.2
* commit 'a1f7844a11010d8552c75424d1a831b37a0ae5d9': pgssubdec: Check RLE size before copying See: c0d68be555f5858703383040e04fcd6529777061 Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/pgssubdec.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 71c367ce6f..07ea8b71f5 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -214,6 +214,13 @@ static int parse_picture_segment(AVCodecContext *avctx,
/* Decode rle bitmap length, stored size includes width/height data */
rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
+ if (buf_size > rle_bitmap_len) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Buffer dimension %d larger than the expected RLE data %d\n",
+ buf_size, rle_bitmap_len);
+ return AVERROR_INVALIDDATA;
+ }
+
/* Get bitmap dimensions from data */
width = bytestream_get_be16(&buf);
height = bytestream_get_be16(&buf);
@@ -224,11 +231,6 @@ static int parse_picture_segment(AVCodecContext *avctx,
return -1;
}
- if (buf_size > rle_bitmap_len) {
- av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
- return AVERROR_INVALIDDATA;
- }
-
ctx->pictures[picture_id].w = width;
ctx->pictures[picture_id].h = height;