initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
BIN
libs/wxWidgets-3.3.1/tests/fuzz/corpus/zip/doc.zip
Normal file
BIN
libs/wxWidgets-3.3.1/tests/fuzz/corpus/zip/doc.zip
Normal file
Binary file not shown.
BIN
libs/wxWidgets-3.3.1/tests/fuzz/corpus/zip/pages.zip
Normal file
BIN
libs/wxWidgets-3.3.1/tests/fuzz/corpus/zip/pages.zip
Normal file
Binary file not shown.
BIN
libs/wxWidgets-3.3.1/tests/fuzz/corpus/zip/test.zip
Normal file
BIN
libs/wxWidgets-3.3.1/tests/fuzz/corpus/zip/test.zip
Normal file
Binary file not shown.
12
libs/wxWidgets-3.3.1/tests/fuzz/ossfuzz.sh
Executable file
12
libs/wxWidgets-3.3.1/tests/fuzz/ossfuzz.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# build project
|
||||
./configure --without-subdirs --disable-shared --disable-sys-libs --disable-gui LDFLAGS="$CXXFLAGS"
|
||||
make -j$(nproc)
|
||||
|
||||
# build fuzzers
|
||||
$CXX $CXXFLAGS -o $OUT/zip tests/fuzz/zip.cpp \
|
||||
$LIB_FUZZING_ENGINE `./wx-config --cxxflags --libs base`
|
||||
|
||||
# and copy their corpora
|
||||
zip -j $OUT/zip_seed_corpus.zip tests/fuzz/corpus/zip/*
|
||||
64
libs/wxWidgets-3.3.1/tests/fuzz/runner.cpp
Normal file
64
libs/wxWidgets-3.3.1/tests/fuzz/runner.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/fuzz/runner.cpp
|
||||
// Purpose: Main function for running fuzzers with a single input file
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2017-10-28
|
||||
// Copyright: (c) 2017 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Normally fuzzers are run by libFuzzer, which executes the entry function
|
||||
// LLVMFuzzerTestOneInput() with many different inputs, but it can be useful to
|
||||
// run them with just a single input to check a particular problem found during
|
||||
// fuzzing. To do this, link the fuzzer code with this file and run it with the
|
||||
// file name containing the test data. E.g. an example use:
|
||||
//
|
||||
// $ g++ -g -fsanitize=undefined tests/fuzz/{zip,runner}.cpp `wx-config --cxxflags --libs base`
|
||||
// $ ./a.out testcase-found-by-libfuzzer
|
||||
|
||||
#include "wx/buffer.h"
|
||||
#include "wx/crt.h"
|
||||
#include "wx/ffile.h"
|
||||
#include "wx/init.h"
|
||||
|
||||
// The fuzzer entry function.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const wxUint8 *data, size_t size);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
wxInitializer init(argc, argv);
|
||||
if ( !init.IsOk() )
|
||||
{
|
||||
wxPrintf("Initializing wxWidgets failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( argc != 2 )
|
||||
{
|
||||
wxPrintf("Usage: %s <input-file>\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
wxFFile file(argv[1], "rb");
|
||||
if ( !file.IsOpened() )
|
||||
{
|
||||
wxPrintf("Failed to open the input file \"%s\".\n", argv[1]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
const wxFileOffset ofs = file.Length();
|
||||
if ( ofs < 0 )
|
||||
{
|
||||
wxPrintf("Failed to get the input file \"%s\" size.\n", argv[1]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
const size_t len = ofs;
|
||||
wxMemoryBuffer buf(len);
|
||||
if ( file.Read(buf.GetData(), len) != len )
|
||||
{
|
||||
wxPrintf("Failed to read from the input file \"%s\".\n", argv[1]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
return LLVMFuzzerTestOneInput(static_cast<wxUint8*>(buf.GetData()), len);
|
||||
}
|
||||
49
libs/wxWidgets-3.3.1/tests/fuzz/zip.cpp
Normal file
49
libs/wxWidgets-3.3.1/tests/fuzz/zip.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/fuzz/zip.cpp
|
||||
// Purpose: ZIP archives reading code fuzzing test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2017-10-24
|
||||
// Copyright: (c) 2017 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/log.h"
|
||||
#include "wx/mstream.h"
|
||||
#include "wx/zipstrm.h"
|
||||
|
||||
#if wxDEBUG_LEVEL
|
||||
|
||||
static void exitAssertHandler(const wxString& file,
|
||||
int line,
|
||||
const wxString& func,
|
||||
const wxString& cond,
|
||||
const wxString& msg);
|
||||
|
||||
static volatile wxAssertHandler_t
|
||||
origAssertHandler = wxSetAssertHandler(exitAssertHandler);
|
||||
|
||||
static void exitAssertHandler(const wxString& file,
|
||||
int line,
|
||||
const wxString& func,
|
||||
const wxString& cond,
|
||||
const wxString& msg)
|
||||
{
|
||||
origAssertHandler(file, line, func, cond, msg);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#endif // wxDEBUG_LEVEL
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const wxUint8 *data, size_t size)
|
||||
{
|
||||
wxLogNull noLog;
|
||||
|
||||
wxMemoryInputStream mis(data, size);
|
||||
wxZipInputStream zis(mis);
|
||||
while ( wxZipEntry* const ze = zis.GetNextEntry() ) {
|
||||
zis.OpenEntry(*ze);
|
||||
delete ze;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user