summaryrefslogtreecommitdiff
path: root/libavcodec/tiff.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-06-03 04:53:02 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-06-07 17:23:53 +0200
commit9c2216976907336dfae0e8e38a4d70ca2465a92c (patch)
treeb4bba5303f0f5a4985dec46b42c2f8eab0a7ec1c /libavcodec/tiff.c
parent999ccd2d0a43640921088578f138c874f6cc0f8a (diff)
tiff: do not overread the source buffer
At least 2 bytes from the source are read every loop. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org
Diffstat (limited to 'libavcodec/tiff.c')
-rw-r--r--libavcodec/tiff.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index edef8308b8..735eafe721 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -224,10 +224,13 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
break;
case TIFF_PACKBITS:
for (pixels = 0; pixels < width;) {
+ if (ssrc + size - src < 2)
+ return AVERROR_INVALIDDATA;
code = (int8_t) *src++;
if (code >= 0) {
code++;
- if (pixels + code > width) {
+ if (pixels + code > width ||
+ ssrc + size - src < code) {
av_log(s->avctx, AV_LOG_ERROR,
"Copy went out of bounds\n");
return AVERROR_INVALIDDATA;