2019-06-23 18:31:35 +00:00
|
|
|
#include <qpdf/Pl_Discard.hh>
|
|
|
|
#include <qpdf/Pl_TIFFPredictor.hh>
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
class FuzzHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FuzzHelper(unsigned char const* data, size_t size);
|
|
|
|
void run();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void doChecks();
|
|
|
|
|
|
|
|
unsigned char const* data;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
FuzzHelper::FuzzHelper(unsigned char const* data, size_t size) :
|
|
|
|
data(data),
|
|
|
|
size(size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FuzzHelper::doChecks()
|
|
|
|
{
|
|
|
|
Pl_Discard discard;
|
2023-05-21 17:35:09 +00:00
|
|
|
Pl_TIFFPredictor p("decoder", &discard, Pl_TIFFPredictor::a_decode, 16, 1, 8);
|
2019-06-23 18:31:35 +00:00
|
|
|
p.write(const_cast<unsigned char*>(data), size);
|
|
|
|
p.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FuzzHelper::run()
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
try {
|
2019-06-23 18:31:35 +00:00
|
|
|
doChecks();
|
2022-04-02 21:14:10 +00:00
|
|
|
} catch (std::runtime_error const& e) {
|
2019-06-23 18:31:35 +00:00
|
|
|
std::cerr << "runtime_error: " << e.what() << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
extern "C" int
|
|
|
|
LLVMFuzzerTestOneInput(unsigned char const* data, size_t size)
|
2019-06-23 18:31:35 +00:00
|
|
|
{
|
|
|
|
FuzzHelper f(data, size);
|
|
|
|
f.run();
|
|
|
|
return 0;
|
|
|
|
}
|