mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Add setMaxWarnings rather than using conditional compilation
This commit is contained in:
parent
65bd8bc57d
commit
598268f6ad
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2024-07-02 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Add QPDF::setMaxWarnings to set the maximum of warnings before
|
||||||
|
warning suppression.
|
||||||
|
|
||||||
|
* Add additional options to Pl_DCT construction to limit sizes and
|
||||||
|
memory usage of compression. These are generally exposed but are
|
||||||
|
primarily intended to support fuzz tests, which have explicit
|
||||||
|
memory limits that are smaller than what is commonly seen in the
|
||||||
|
wild with PDF files.
|
||||||
|
|
||||||
2024-06-07 Jay Berkenbilt <ejb@ql.org>
|
2024-06-07 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* 11.9.1: release
|
* 11.9.1: release
|
||||||
|
@ -57,6 +57,7 @@ FuzzHelper::getQpdf()
|
|||||||
auto is =
|
auto is =
|
||||||
std::shared_ptr<InputSource>(new BufferInputSource("fuzz input", &this->input_buffer));
|
std::shared_ptr<InputSource>(new BufferInputSource("fuzz input", &this->input_buffer));
|
||||||
auto qpdf = QPDF::create();
|
auto qpdf = QPDF::create();
|
||||||
|
qpdf->setMaxWarnings(20);
|
||||||
qpdf->processInputSource(is);
|
qpdf->processInputSource(is);
|
||||||
return qpdf;
|
return qpdf;
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,10 @@ class QPDF
|
|||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void setSuppressWarnings(bool);
|
void setSuppressWarnings(bool);
|
||||||
|
|
||||||
|
// Set the maximum number of warnings to output. Subsequent warnings are suppressed.
|
||||||
|
QPDF_DLL
|
||||||
|
void setMaxWarnings(int);
|
||||||
|
|
||||||
// By default, QPDF will try to recover if it finds certain types of errors in PDF files. If
|
// By default, QPDF will try to recover if it finds certain types of errors in PDF files. If
|
||||||
// turned off, it will throw an exception on the first such problem it finds without attempting
|
// turned off, it will throw an exception on the first such problem it finds without attempting
|
||||||
// recovery.
|
// recovery.
|
||||||
@ -1497,6 +1501,7 @@ class QPDF
|
|||||||
bool provided_password_is_hex_key{false};
|
bool provided_password_is_hex_key{false};
|
||||||
bool ignore_xref_streams{false};
|
bool ignore_xref_streams{false};
|
||||||
bool suppress_warnings{false};
|
bool suppress_warnings{false};
|
||||||
|
int max_warnings{0};
|
||||||
bool attempt_recovery{true};
|
bool attempt_recovery{true};
|
||||||
bool check_mode{false};
|
bool check_mode{false};
|
||||||
std::shared_ptr<EncryptionParameters> encp;
|
std::shared_ptr<EncryptionParameters> encp;
|
||||||
|
@ -331,6 +331,12 @@ QPDF::setSuppressWarnings(bool val)
|
|||||||
m->suppress_warnings = val;
|
m->suppress_warnings = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
QPDF::setMaxWarnings(int val)
|
||||||
|
{
|
||||||
|
m->suppress_warnings = val;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDF::setAttemptRecovery(bool val)
|
QPDF::setAttemptRecovery(bool val)
|
||||||
{
|
{
|
||||||
@ -500,14 +506,11 @@ QPDF::warn(QPDFExc const& e)
|
|||||||
{
|
{
|
||||||
m->warnings.push_back(e);
|
m->warnings.push_back(e);
|
||||||
if (!m->suppress_warnings) {
|
if (!m->suppress_warnings) {
|
||||||
// QXXXQ
|
if (m->max_warnings > 0 && m->warnings.size() > 20) {
|
||||||
#ifdef QPDF_OSS_FUZZ
|
*m->log->getWarn() << "WARNING: too many warnings - additional warnings suppressed\n";
|
||||||
if (m->warnings.size() > 20) {
|
|
||||||
*m->log->getWarn() << "WARNING: too many warnings - additional warnings surpressed\n";
|
|
||||||
m->suppress_warnings = true;
|
m->suppress_warnings = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*m->log->getWarn() << "WARNING: " << m->warnings.back().what() << "\n";
|
*m->log->getWarn() << "WARNING: " << m->warnings.back().what() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user