From 6a0253dab60fb9e94e5d9a21826cf1bc6e83e03a Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 23 Sep 2013 17:46:53 +0100 Subject: Bug 694566: Avoid locking up while seeking in deflated stream. In streams that we cannot seek in (such as flate ones) we implement seeking forward by skipping bytes. We failed to spot that we hit EOF, and spent ages just looping. Fix is simply to spot that we hit EOF and bale with a warning. --- source/fitz/stream-read.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index d433ce32..71ae7666 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -217,7 +217,13 @@ fz_seek(fz_stream *stm, int offset, int whence) fz_warn(stm->ctx, "cannot seek backwards"); /* dog slow, but rare enough */ while (offset-- > 0) - fz_read_byte(stm); + { + if (fz_read_byte(stm) == EOF) + { + fz_warn(stm->ctx, "seek failed"); + break; + } + } } else fz_warn(stm->ctx, "cannot seek"); -- cgit v1.2.3