summaryrefslogtreecommitdiff
path: root/pdf/pdf_xref.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-03-05 00:02:02 +0000
committerRobin Watts <robin.watts@artifex.com>2013-03-05 10:42:20 +0000
commit1b4b5fdfa6b74827631d42efd2a61226125f036b (patch)
treea2ab9f8d03674885c130b91621fd619713d2b935 /pdf/pdf_xref.c
parent4c45666cb302a7eab95d362989c0e7e087d8383f (diff)
downloadmupdf-1b4b5fdfa6b74827631d42efd2a61226125f036b.tar.xz
Fix warnings seen on cleaning a document.
Seen with the test file from bu 693677. When we read a file in, we read the trailer, and the encrypt object before we start to decrypt other objects. These objects do not make it into the xref table though. When we write a file out, we run through the file reading in objects prior to writing them out; when we read in the trailer and the encrypt object we therefore try to decrypt them, giving errors. To avoid these errors, put the trailer and the encrypt object into the xref table when they are first read. This solves all but 1 problem when cleaning this file with "-dif" (as the signature object contains a digest block of data that is unencrypted). This solves all but 3 problems when cleaning this file with "-difggg"; the signature object, and one orphan copy of the crypt dictionary that is reported twice.
Diffstat (limited to 'pdf/pdf_xref.c')
-rw-r--r--pdf/pdf_xref.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index 7914876e..ac89109d 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -123,7 +123,17 @@ pdf_read_new_trailer(pdf_document *xref, pdf_lexbuf *buf)
{
fz_try(xref->ctx)
{
- xref->trailer = pdf_parse_ind_obj(xref, xref->file, buf, NULL, NULL, NULL);
+ int num, gen, stm_ofs, ofs;
+ ofs = fz_tell(xref->file);
+ xref->trailer = pdf_parse_ind_obj(xref, xref->file, buf, &num, &gen, &stm_ofs);
+ if (num > xref->len)
+ pdf_resize_xref(xref, num+1);
+ xref->table[num].ofs = ofs;
+ xref->table[num].gen = gen;
+ xref->table[num].stm_ofs = stm_ofs;
+ pdf_drop_obj(xref->table[num].obj);
+ xref->table[num].obj = pdf_keep_obj(xref->trailer);
+ xref->table[num].type = 'n';
}
fz_catch(xref->ctx)
{
@@ -322,7 +332,16 @@ pdf_read_new_xref(pdf_document *xref, pdf_lexbuf *buf)
fz_try(ctx)
{
+ int ofs = fz_tell(xref->file);
trailer = pdf_parse_ind_obj(xref, xref->file, buf, &num, &gen, &stm_ofs);
+ if (num > xref->len)
+ pdf_resize_xref(xref, num+1);
+ xref->table[num].ofs = ofs;
+ xref->table[num].gen = gen;
+ xref->table[num].stm_ofs = stm_ofs;
+ pdf_drop_obj(xref->table[num].obj);
+ xref->table[num].obj = pdf_keep_obj(trailer);
+ xref->table[num].type = 'n';
}
fz_catch(ctx)
{