summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-10-06 04:08:29 +0200
committerTor Andersson <tor@ghostscript.com>2004-10-06 04:08:29 +0200
commitb6d5eb5a22b9faa1155a9cfcf76ff690ebebea07 (patch)
treeda7c790b52edd0ebf82fc8043c7f8c06702efca6
parent6729fc0287191d7906ba643db3317d784bb22f57 (diff)
downloadmupdf-b6d5eb5a22b9faa1155a9cfcf76ff690ebebea07.tar.xz
advance file position on lexing errors so we dont loop forever
-rw-r--r--mupdf/repair.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/mupdf/repair.c b/mupdf/repair.c
index abc69cbc..0d6bffcb 100644
--- a/mupdf/repair.c
+++ b/mupdf/repair.c
@@ -65,7 +65,7 @@ parseobj(fz_file *file, unsigned char *buf, int cap, int *stmlen,
}
stmofs = fz_tell(file);
-
+
length = fz_dictgets(dict, "Length");
if (fz_isint(length))
{
@@ -76,17 +76,17 @@ parseobj(fz_file *file, unsigned char *buf, int cap, int *stmlen,
fz_seek(file, stmofs);
}
- fz_read(file, buf, 8);
- while (memcmp(buf, "endstream", 8) != 0)
+ fz_read(file, buf, 9);
+ while (memcmp(buf, "endstream", 9) != 0)
{
c = fz_readbyte(file);
if (c == EOF)
break;
- memmove(buf, buf + 1, 7);
- buf[7] = c;
+ memmove(buf, buf + 1, 8);
+ buf[8] = c;
}
- *stmlen = fz_tell(file) - stmofs - 8;
+ *stmlen = fz_tell(file) - stmofs - 9;
atobjend:
tok = pdf_lex(file, buf, cap, &len);
@@ -162,7 +162,6 @@ pdf_repairxref(pdf_xref *xref, char *filename)
if (tok == PDF_TOBJ)
{
-
error = parseobj(file, buf, sizeof buf, &stmlen, &isroot, &isinfo);
if (error)
goto cleanup;
@@ -199,6 +198,9 @@ pdf_repairxref(pdf_xref *xref, char *filename)
maxoid = oid;
}
+ if (tok == PDF_TERROR)
+ fz_readbyte(file);
+
if (tok == PDF_TEOF)
break;
}