Skip to content

Commit

Permalink
fuzzer: limit input size to avoid useless testing of huge proj strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 24, 2019
1 parent 36beda5 commit e658bbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/fuzzers/build_google_oss_fuzzers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ build_fuzzer()
}

build_fuzzer standard_fuzzer $(dirname $0)/standard_fuzzer.cpp

echo "[libfuzzer]" > $OUT/standard_fuzzer.options
echo "max_len = 10000" >> $OUT/standard_fuzzer.options
8 changes: 8 additions & 0 deletions test/fuzzers/standard_fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ int LLVMFuzzerInitialize(int* /*argc*/, char*** argv)

int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
{
if( len > 1000 )
{
#ifdef STANDALONE
fprintf(stderr, "Input too large\n");
#endif
return 0;
}

/* We expect the blob to be 3 lines: */
/* source proj string\ndestination proj string\nx y */
char* buf_dup = (char*)malloc(len+1);
Expand Down

0 comments on commit e658bbc

Please sign in to comment.