Files
wxWidgets/tests/fuzz/tar.cpp
T
Arthur Chan aef89c0e87
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxQt (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxX11 (push) Has been cancelled
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Has been cancelled
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxDFB (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Has been cancelled
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Has been cancelled
CMake builds / macOS latest wxGTK 3 Unix Makefiles (push) Has been cancelled
CMake builds / MSW/MSVC wxMSW (push) Has been cancelled
CMake builds / MSW/Clang wxMSW (push) Has been cancelled
CMake builds / macOS latest wxOSX Ninja (push) Has been cancelled
CMake builds / macOS 14 wxOSX Xcode (push) Has been cancelled
CMake builds / macOS 14 wxIOS (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 5.15 (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 6.10 (push) Has been cancelled
Mac builds / wxMac ARM ASAN not compatible (push) Has been cancelled
Mac builds / wxMac Universal C++14 (push) Has been cancelled
Mac builds / wxiOS Simulator on Silicon Mac (push) Has been cancelled
Mac builds / wxiOS (push) Has been cancelled
Mac builds / wxMac Intel C++17 (push) Has been cancelled
Mac Xcode builds / iOS Simulator static (push) Has been cancelled
Mac Xcode builds / macOS dynamic Release (push) Has been cancelled
Mac Xcode builds / iOS static Debug (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Release x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 Debug Win32 (push) Has been cancelled
MSW builds / wxMSW vs2022 Release arm64 (push) Has been cancelled
MSW builds / wxMSW vs2026 DLL Release x64 (push) Has been cancelled
MSW cross-builds / wxMSW 64 bits not compatible (push) Has been cancelled
MSW cross-builds / wxMSW/Univ (push) Has been cancelled
MSW cross-builds / wxMSW 32 bits (push) Has been cancelled
Code Checks / Check Spelling (push) Has been cancelled
Code Checks / Check Whitespace (push) Has been cancelled
Code Checks / Check Mixed EOL (push) Has been cancelled
Code Checks / Check C++ Style (push) Has been cancelled
Code Checks / Check All Headers In allheaders.h (push) Has been cancelled
OSS-Fuzz: Add new fuzzer targets tar operation
Add a new OSS-Fuzz fuzzer targeting tar operation, mirroring the
existing zip fuzzer.

Closes #26579.

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-06-11 23:57:23 +02:00

59 lines
1.7 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: tests/fuzz/tar.cpp
// Purpose: TAR archives reading code fuzzing test
// Author: Arthur Chan
// Created: 2026-06-11
// Copyright: (c) 2026 Arthur Chan
///////////////////////////////////////////////////////////////////////////////
#include "wx/log.h"
#include "wx/mstream.h"
#include "wx/tarstrm.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);
wxTarInputStream tis(mis);
while ( wxTarEntry* const te = tis.GetNextEntry() ) {
if ( tis.OpenEntry(*te) ) {
// Read the entry data to exercise the size/offset parsing and OnSysRead
char buf[4096];
while ( tis.IsOk() && !tis.Eof() ) {
tis.Read(buf, sizeof(buf));
if ( tis.LastRead() == 0 )
break;
}
tis.CloseEntry();
}
delete te;
}
return 0;
}