mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-14 08:44:04 +00:00
53 lines
891 B
C++
53 lines
891 B
C++
#include <qpdf/Pl_Discard.hh>
|
|
#include <qpdf/Pl_LZWDecoder.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;
|
|
Pl_LZWDecoder p("decode", &discard, false);
|
|
p.write(const_cast<unsigned char*>(data), size);
|
|
p.finish();
|
|
}
|
|
|
|
void
|
|
FuzzHelper::run()
|
|
{
|
|
try
|
|
{
|
|
doChecks();
|
|
}
|
|
catch (std::runtime_error const& e)
|
|
{
|
|
std::cerr << "runtime_error: " << e.what() << std::endl;
|
|
}
|
|
}
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(unsigned char const* data, size_t size)
|
|
{
|
|
FuzzHelper f(data, size);
|
|
f.run();
|
|
return 0;
|
|
}
|