oss-fuzz: max size of input data to analyze 10000
This commit is contained in:
parent
b0c58f2b10
commit
8f9c4ec4a2
|
@ -27,10 +27,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize)
|
||||||
|
{
|
||||||
CppcheckExecutor cppcheckExecutor;
|
if (dataSize < 10000) {
|
||||||
cppcheckExecutor.run(generateCode2(data, dataSize));
|
CppcheckExecutor cppcheckExecutor;
|
||||||
|
cppcheckExecutor.run(generateCode2(data, dataSize));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
#include "type2.h"
|
#include "type2.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
const char *filename = argc==2 ? argv[1] : nullptr;
|
const char *filename = argc==2 ? argv[1] : nullptr;
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int getValue(const uint8_t *data, size_t dataSize, uint8_t maxValue, bool *done = nullptr) {
|
static int getValue(const uint8_t *data, size_t dataSize, uint8_t maxValue, bool *done = nullptr)
|
||||||
|
{
|
||||||
static size_t pos; // current "data" position
|
static size_t pos; // current "data" position
|
||||||
static int dataValue; // value extracted from data
|
static int dataValue; // value extracted from data
|
||||||
static int ones; // ones. This variable tracks if we need to add more stuff in "dataValue".
|
static int ones; // ones. This variable tracks if we need to add more stuff in "dataValue".
|
||||||
|
@ -29,14 +30,15 @@ static int getValue(const uint8_t *data, size_t dataSize, uint8_t maxValue, bool
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string generateExpression2_lvalue(const uint8_t *data, size_t dataSize) {
|
static std::string generateExpression2_lvalue(const uint8_t *data, size_t dataSize)
|
||||||
|
{
|
||||||
return "var" + std::to_string(1 + getValue(data, dataSize, 5));
|
return "var" + std::to_string(1 + getValue(data, dataSize, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string generateExpression2_Op(const uint8_t *data, size_t dataSize, int numberOfGlobalConstants) {
|
static std::string generateExpression2_Op(const uint8_t *data, size_t dataSize, int numberOfGlobalConstants)
|
||||||
|
{
|
||||||
std::ostringstream code;
|
std::ostringstream code;
|
||||||
switch (getValue(data, dataSize, 3))
|
switch (getValue(data, dataSize, 3)) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
code << generateExpression2_lvalue(data, dataSize);
|
code << generateExpression2_lvalue(data, dataSize);
|
||||||
break;
|
break;
|
||||||
|
@ -50,7 +52,8 @@ static std::string generateExpression2_Op(const uint8_t *data, size_t dataSize,
|
||||||
return code.str();
|
return code.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string generateExpression2_Expr(const uint8_t *data, size_t dataSize, int numberOfGlobalConstants, int depth=0) {
|
static std::string generateExpression2_Expr(const uint8_t *data, size_t dataSize, int numberOfGlobalConstants, int depth=0)
|
||||||
|
{
|
||||||
++depth;
|
++depth;
|
||||||
const unsigned int type = (depth > 3) ? 0 : getValue(data, dataSize, 3);
|
const unsigned int type = (depth > 3) ? 0 : getValue(data, dataSize, 3);
|
||||||
const char binop[] = "=<>+-*/%&|^";
|
const char binop[] = "=<>+-*/%&|^";
|
||||||
|
@ -94,7 +97,8 @@ static std::string generateExpression2_Cond(const uint8_t *data, size_t dataSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static std::string functionStart() {
|
static std::string functionStart()
|
||||||
|
{
|
||||||
static int functionNumber;
|
static int functionNumber;
|
||||||
return "int f" + std::to_string(++functionNumber) + "()\n"
|
return "int f" + std::to_string(++functionNumber) + "()\n"
|
||||||
"{\n";
|
"{\n";
|
||||||
|
@ -112,8 +116,7 @@ static std::string generateExpression2_conditionalCode(const std::string &indent
|
||||||
else
|
else
|
||||||
code << indent << "{\n";
|
code << indent << "{\n";
|
||||||
|
|
||||||
for (int line = 0; line < 4 || indent.empty(); ++line)
|
for (int line = 0; line < 4 || indent.empty(); ++line) {
|
||||||
{
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
const int type1 = getValue(data, dataSize, 8, &done);
|
const int type1 = getValue(data, dataSize, 8, &done);
|
||||||
if (done)
|
if (done)
|
||||||
|
@ -154,7 +157,8 @@ static std::string generateExpression2_conditionalCode(const std::string &indent
|
||||||
return code.str();
|
return code.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateCode2(const uint8_t *data, size_t dataSize) {
|
std::string generateCode2(const uint8_t *data, size_t dataSize)
|
||||||
|
{
|
||||||
std::ostringstream code;
|
std::ostringstream code;
|
||||||
|
|
||||||
// create global constants
|
// create global constants
|
||||||
|
|
|
@ -52,6 +52,8 @@ formatCplusplusRecursive "gui/test/*.cpp"
|
||||||
formatCplusplusRecursive "gui/test/*.h"
|
formatCplusplusRecursive "gui/test/*.h"
|
||||||
formatCplusplus "lib/*.cpp"
|
formatCplusplus "lib/*.cpp"
|
||||||
formatCplusplus "lib/*.h"
|
formatCplusplus "lib/*.h"
|
||||||
|
formatCplusplus "oss-fuzz/*.cpp"
|
||||||
|
formatCplusplus "oss-fuzz/*.h"
|
||||||
formatCplusplus "test/*.cpp"
|
formatCplusplus "test/*.cpp"
|
||||||
formatCplusplus "test/cfg/*.c"
|
formatCplusplus "test/cfg/*.c"
|
||||||
formatCplusplus "test/cfg/*.cpp"
|
formatCplusplus "test/cfg/*.cpp"
|
||||||
|
|
Loading…
Reference in New Issue