From 0f9722d6a9351b4a89a1ce27dcd7173db87a74ef Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 15 Jun 2010 01:30:07 +0200 Subject: Seek to the indicated offsets when loading objects in a compressed object stream. This will safeguard against invalid PDF files that embed sub-streams in compressed object streams. --- mupdf/pdf_xref.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mupdf/pdf_xref.c b/mupdf/pdf_xref.c index b1908702..c55c2feb 100644 --- a/mupdf/pdf_xref.c +++ b/mupdf/pdf_xref.c @@ -61,10 +61,10 @@ pdf_debugxref(pdf_xref *xref) printf("xref\n0 %d\n", xref->len); for (i = 0; i < xref->len; i++) { - printf("%010d %05d %c (ref=%d, ofs=%d)\n", + printf("%05d: %010d %05d %c (refs=%d, stmofs=%d)\n", i, xref->table[i].ofs, xref->table[i].gen, - xref->table[i].type, + xref->table[i].type ? xref->table[i].type : '-', xref->table[i].obj ? xref->table[i].obj->refs : 0, xref->table[i].stmofs); } @@ -138,7 +138,12 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) for (i = 0; i < count; i++) { - /* FIXME: seek to first + ofsbuf[i] */ + error = fz_seek(stm, first + ofsbuf[i], 0); + if (error) + { + error = fz_rethrow(error, "cannot seek in object stream (%d %d R)", num, gen); + goto cleanupstm; + } error = pdf_parsestmobj(&obj, xref, stm, buf, cap); if (error) -- cgit v1.2.3