Commit 44736387 authored by Alex Converse's avatar Alex Converse

tiff: Prevent overreads in the type_sizes array.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
parent e32548d1
...@@ -289,6 +289,11 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t * ...@@ -289,6 +289,11 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
count = tget_long(&buf, s->le); count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le); off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n", type);
return 0;
}
if(count == 1){ if(count == 1){
switch(type){ switch(type){
case TIFF_BYTE: case TIFF_BYTE:
...@@ -310,10 +315,12 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t * ...@@ -310,10 +315,12 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
value = UINT_MAX; value = UINT_MAX;
buf = start + off; buf = start + off;
} }
}else if(type_sizes[type] * count <= 4){ } else {
buf -= 4; if (count <= 4 && type_sizes[type] * count <= 4) {
}else{ buf -= 4;
buf = start + off; } else {
buf = start + off;
}
} }
if(buf && (buf < start || buf > end_buf)){ if(buf && (buf < start || buf > end_buf)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment