mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-11 16:18:54 +00:00
Rename Pl_Flate::setMemoryLimit to memory_limit and add accessor
This commit is contained in:
parent
a496dbe8b2
commit
b0e34486fd
@ -111,7 +111,7 @@ FuzzHelper::doChecks()
|
||||
Pl_PNGFilter::setMemoryLimit(1'000'000);
|
||||
Pl_RunLength::setMemoryLimit(1'000'000);
|
||||
Pl_TIFFPredictor::setMemoryLimit(1'000'000);
|
||||
Pl_Flate::setMemoryLimit(200'000);
|
||||
Pl_Flate::memory_limit(200'000);
|
||||
|
||||
// Do not decompress corrupt data. This may cause extended runtime within jpeglib without
|
||||
// exercising additional code paths in qpdf, and potentially causing counterproductive timeouts.
|
||||
|
@ -111,7 +111,7 @@ FuzzHelper::doChecks()
|
||||
Pl_PNGFilter::setMemoryLimit(1'000'000);
|
||||
Pl_RunLength::setMemoryLimit(1'000'000);
|
||||
Pl_TIFFPredictor::setMemoryLimit(1'000'000);
|
||||
Pl_Flate::setMemoryLimit(200'000);
|
||||
Pl_Flate::memory_limit(200'000);
|
||||
|
||||
// Do not decompress corrupt data. This may cause extended runtime within jpeglib without
|
||||
// exercising additional code paths in qpdf, and potentially causing counterproductive timeouts.
|
||||
|
@ -109,7 +109,7 @@ FuzzHelper::doChecks()
|
||||
Pl_PNGFilter::setMemoryLimit(1'000'000);
|
||||
Pl_RunLength::setMemoryLimit(1'000'000);
|
||||
Pl_TIFFPredictor::setMemoryLimit(1'000'000);
|
||||
Pl_Flate::setMemoryLimit(200'000);
|
||||
Pl_Flate::memory_limit(200'000);
|
||||
|
||||
// Do not decompress corrupt data. This may cause extended runtime within jpeglib without
|
||||
// exercising additional code paths in qpdf, and potentially causing counterproductive timeouts.
|
||||
|
@ -110,7 +110,7 @@ FuzzHelper::doChecks()
|
||||
Pl_PNGFilter::setMemoryLimit(1'000'000);
|
||||
Pl_RunLength::setMemoryLimit(1'000'000);
|
||||
Pl_TIFFPredictor::setMemoryLimit(1'000'000);
|
||||
Pl_Flate::setMemoryLimit(200'000);
|
||||
Pl_Flate::memory_limit(200'000);
|
||||
|
||||
// Do not decompress corrupt data. This may cause extended runtime within jpeglib without
|
||||
// exercising additional code paths in qpdf, and potentially causing counterproductive timeouts.
|
||||
|
@ -87,7 +87,7 @@ FuzzHelper::doChecks()
|
||||
Pl_PNGFilter::setMemoryLimit(1'000'000);
|
||||
Pl_RunLength::setMemoryLimit(1'000'000);
|
||||
Pl_TIFFPredictor::setMemoryLimit(1'000'000);
|
||||
Pl_Flate::setMemoryLimit(200'000);
|
||||
Pl_Flate::memory_limit(200'000);
|
||||
|
||||
// Do not decompress corrupt data. This may cause extended runtime within jpeglib without
|
||||
// exercising additional code paths in qpdf, and potentially causing counterproductive timeouts.
|
||||
|
@ -108,7 +108,7 @@ FuzzHelper::doChecks()
|
||||
Pl_PNGFilter::setMemoryLimit(1'000'000);
|
||||
Pl_RunLength::setMemoryLimit(1'000'000);
|
||||
Pl_TIFFPredictor::setMemoryLimit(1'000'000);
|
||||
Pl_Flate::setMemoryLimit(200'000);
|
||||
Pl_Flate::memory_limit(200'000);
|
||||
|
||||
// Do not decompress corrupt data. This may cause extended runtime within jpeglib without
|
||||
// exercising additional code paths in qpdf, and potentially causing counterproductive timeouts.
|
||||
|
@ -48,7 +48,9 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline
|
||||
// Limit the memory used.
|
||||
// NB This is a static option affecting all Pl_Flate instances.
|
||||
QPDF_DLL
|
||||
static void setMemoryLimit(unsigned long long limit);
|
||||
static unsigned long long memory_limit();
|
||||
QPDF_DLL
|
||||
static void memory_limit(unsigned long long limit);
|
||||
|
||||
QPDF_DLL
|
||||
void write(unsigned char const* data, size_t len) override;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
unsigned long long memory_limit{0};
|
||||
unsigned long long memory_limit_{0};
|
||||
} // namespace
|
||||
|
||||
int Pl_Flate::compression_level = Z_DEFAULT_COMPRESSION;
|
||||
@ -80,10 +80,16 @@ Pl_Flate::~Pl_Flate() // NOLINT (modernize-use-equals-default)
|
||||
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
|
||||
}
|
||||
|
||||
void
|
||||
Pl_Flate::setMemoryLimit(unsigned long long limit)
|
||||
unsigned long long
|
||||
Pl_Flate::memory_limit()
|
||||
{
|
||||
memory_limit = limit;
|
||||
return memory_limit_;
|
||||
}
|
||||
|
||||
void
|
||||
Pl_Flate::memory_limit(unsigned long long limit)
|
||||
{
|
||||
memory_limit_ = limit;
|
||||
}
|
||||
|
||||
void
|
||||
@ -197,9 +203,9 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
|
||||
}
|
||||
uLong ready = QIntC::to_ulong(m->out_bufsize - zstream.avail_out);
|
||||
if (ready > 0) {
|
||||
if (memory_limit && m->action != a_deflate) {
|
||||
if (memory_limit_ && m->action != a_deflate) {
|
||||
m->written += ready;
|
||||
if (m->written > memory_limit) {
|
||||
if (m->written > memory_limit_) {
|
||||
throw std::runtime_error("PL_Flate memory limit exceeded");
|
||||
}
|
||||
}
|
||||
@ -220,7 +226,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
|
||||
void
|
||||
Pl_Flate::finish()
|
||||
{
|
||||
if (m->written > memory_limit) {
|
||||
if (m->written > memory_limit_) {
|
||||
throw std::runtime_error("PL_Flate memory limit exceeded");
|
||||
}
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user