initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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/*

View 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);
}

View 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;
}