From a6f0d56d2d2e66cef2b4ca6e810bf3630ed53d0b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 9 Jun 2014 14:02:16 +0200 Subject: Fix 695300: don't throw exception on invalid reference number. Return the null object rather than throwing an exception when parsing indirect object references with negative object numbers. Do range check for object numbers (1 .. length) when object numbers are used instead. Object number 0 is not a valid object number. It must always be 'free'. --- source/pdf/pdf-stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/pdf/pdf-stream.c') diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c index 54cf87fe..930c30cb 100644 --- a/source/pdf/pdf-stream.c +++ b/source/pdf/pdf-stream.c @@ -8,7 +8,7 @@ pdf_is_stream(pdf_document *doc, int num, int gen) { pdf_xref_entry *entry; - if (num < 0 || num >= pdf_xref_len(doc)) + if (num <= 0 || num >= pdf_xref_len(doc)) return 0; pdf_cache_object(doc, num, gen); @@ -405,7 +405,7 @@ pdf_open_raw_renumbered_stream(pdf_document *doc, int num, int gen, int orig_num { pdf_xref_entry *x; - if (num < 0 || num >= pdf_xref_len(doc)) + if (num <= 0 || num >= pdf_xref_len(doc)) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "object id out of range (%d %d R)", num, gen); pdf_cache_object(doc, num, gen); @@ -422,7 +422,7 @@ pdf_open_image_stream(pdf_document *doc, int num, int gen, int orig_num, int ori { pdf_xref_entry *x; - if (num < 0 || num >= pdf_xref_len(doc)) + if (num <= 0 || num >= pdf_xref_len(doc)) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "object id out of range (%d %d R)", num, gen); pdf_cache_object(doc, num, gen); -- cgit v1.2.3