summaryrefslogtreecommitdiff
path: root/libavcodec/tiff.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-09-12 19:55:09 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2022-09-16 21:30:57 +0200
commit43a4854510a3d596e114d899177a5b3b323ca9fb (patch)
treeffb4f0eb077cda6f1a1c31d56c2a62321c586d90 /libavcodec/tiff.c
parentfb233771ce3205d25551df1c031eb520ca9d7a99 (diff)
avcodec/tiff: Fix loop detection
Fixes regression with tickets/4364/L1004220.DNG Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/tiff.c')
-rw-r--r--libavcodec/tiff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index beb427e007..226050744f 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1747,7 +1747,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
int *got_frame, AVPacket *avpkt)
{
TiffContext *const s = avctx->priv_data;
- unsigned off, last_off;
+ unsigned off, last_off = 0;
int le, ret, plane, planes;
int i, j, entries, stride;
unsigned soff, ssize;
@@ -1812,7 +1812,6 @@ again:
/** 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);
@@ -1830,6 +1829,7 @@ again:
avpriv_request_sample(s->avctx, "non increasing IFD offset");
return AVERROR_INVALIDDATA;
}
+ last_off = off;
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;