mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Merge pull request #1288 from m-holger/fuzz
In QPDFParser add a limit on total number of errors in one object
This commit is contained in:
commit
7d34b89a69
@ -469,14 +469,15 @@ QPDFParser::fixMissingKeys()
|
||||
bool
|
||||
QPDFParser::tooManyBadTokens()
|
||||
{
|
||||
if (good_count <= 4) {
|
||||
if (--max_bad_count > 0 && good_count > 4) {
|
||||
good_count = 0;
|
||||
bad_count = 1;
|
||||
return false;
|
||||
}
|
||||
if (++bad_count > 5) {
|
||||
warn("too many errors; giving up on reading object");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
bad_count = 1;
|
||||
}
|
||||
good_count = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -83,9 +83,11 @@ class QPDFParser
|
||||
std::vector<StackFrame> stack;
|
||||
StackFrame* frame;
|
||||
// Number of recent bad tokens.
|
||||
int bad_count = 0;
|
||||
int bad_count{0};
|
||||
// Number of bad tokens (remaining) before giving up.
|
||||
int max_bad_count{15};
|
||||
// Number of good tokens since last bad token. Irrelevant if bad_count == 0.
|
||||
int good_count = 0;
|
||||
int good_count{0};
|
||||
// Start offset including any leading whitespace.
|
||||
qpdf_offset_t start;
|
||||
// Number of successive integer tokens.
|
||||
|
Loading…
Reference in New Issue
Block a user