TiffContext *const s = avctx->priv_data;
AVFrame *const p = data;
ThreadFrame frame = { .f = data };
- unsigned off;
+ unsigned off, last_off;
int le, ret, plane, planes;
int i, j, entries, stride;
unsigned soff, ssize;
/** whether we should process this multi-page IFD's next page */
retry_for_page = s->get_page && s->cur_page + 1 < s->get_page; // get_page is 1-indexed
+ last_off = off;
if (retry_for_page) {
// set offset to the next IFD
off = ff_tget_long(&s->gb, le);
}
if (retry_for_subifd || retry_for_page) {
+ if (!off) {
+ av_log(avctx, AV_LOG_ERROR, "Requested entry not found\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (off <= last_off) {
+ avpriv_request_sample(s->avctx, "non increasing IFD offset\n");
+ return AVERROR_INVALIDDATA;
+ }
if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
return AVERROR_INVALIDDATA;