summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <[email protected]>2012-11-09 12:13:30 +0100
committerMichael Niedermayer <[email protected]>2012-12-03 20:39:42 +0100
commit0b9be54e97fa574867d5e99a3623d1db7df7b274 (patch)
treed6251ce777e634b896e445a3ab4b6de2b946c927
parent18817d4b803e67fa56882878267519a2d2878283 (diff)
tiffdec: check count in metadata reading.
Fixes out of array access Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit 6d1c5ea04af3e345232aa70c944de961061dab2d)
-rw-r--r--libavcodec/tiff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 579bd0d5f7..d0b302a47d 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -250,7 +250,7 @@ static int add_doubles_metadata(int count,
int i;
double *dp;
- if (count >= INT_MAX / sizeof(int64_t))
+ if (count >= INT_MAX / sizeof(int64_t) || count <= 0)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t))
return AVERROR_INVALIDDATA;
@@ -276,7 +276,7 @@ static int add_shorts_metadata(int count, const char *name,
int i;
int16_t *sp;
- if (count >= INT_MAX / sizeof(int16_t))
+ if (count >= INT_MAX / sizeof(int16_t) || count <= 0)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))
return AVERROR_INVALIDDATA;