aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-08-10 02:46:02 +0200
committerJay Berkenbilt <ejb@ql.org>2017-08-11 03:30:32 +0200
commit3082e4e6066dde405e4f01edec4518fd9f2c3fc7 (patch)
treef1da0dc1522dd12141b9b1aa8055347c39aebf29 /libqpdf/QPDF.cc
parent90840be59448ba92974629c34ef1b844ccf6a0aa (diff)
downloadqpdf-3082e4e6066dde405e4f01edec4518fd9f2c3fc7.tar.zst
Find xref without PCRE
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 295787b1..fc3120bb 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -477,15 +477,21 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
// The PDF spec says xref must be followed by a line
// terminator, but files exist in the wild where it is
// terminated by arbitrary whitespace.
- PCRE xref_re("^xref\\s+");
- PCRE::Match m = xref_re.match(buf);
- if (m)
+ if ((strncmp(buf, "xref", 4) == 0) &&
+ QUtil::is_space(buf[4]))
{
QTC::TC("qpdf", "QPDF xref space",
((buf[4] == '\n') ? 0 :
(buf[4] == '\r') ? 1 :
(buf[4] == ' ') ? 2 : 9999));
- xref_offset = read_xrefTable(xref_offset + m.getMatch(0).length());
+ int skip = 4;
+ // buf is null-terminated, and QUtil::is_space('\0') is
+ // false, so this won't overrun.
+ while (QUtil::is_space(buf[skip]))
+ {
+ ++skip;
+ }
+ xref_offset = read_xrefTable(xref_offset + skip);
}
else
{