Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src)

ADD_EXECUTABLE(fuzz-cgi fuzz-cgi.C)
ADD_EXECUTABLE(fuzz-css fuzz-css.C)
ADD_EXECUTABLE(fuzz-datetime fuzz-datetime.C)
ADD_EXECUTABLE(fuzz-eval fuzz-eval.C)
ADD_EXECUTABLE(fuzz-http fuzz-http.C)
ADD_EXECUTABLE(fuzz-json fuzz-json.C)
Expand All @@ -10,6 +11,7 @@ ADD_EXECUTABLE(fuzz-xml fuzz-xml.C)

TARGET_LINK_LIBRARIES(fuzz-cgi PRIVATE wt $ENV{LIB_FUZZING_ENGINE})
TARGET_LINK_LIBRARIES(fuzz-css PRIVATE wt $ENV{LIB_FUZZING_ENGINE})
TARGET_LINK_LIBRARIES(fuzz-datetime PRIVATE wt $ENV{LIB_FUZZING_ENGINE})
TARGET_LINK_LIBRARIES(fuzz-eval PRIVATE wt $ENV{LIB_FUZZING_ENGINE})
TARGET_LINK_LIBRARIES(fuzz-http PRIVATE wt wthttp $ENV{LIB_FUZZING_ENGINE})
TARGET_LINK_LIBRARIES(fuzz-json PRIVATE wt $ENV{LIB_FUZZING_ENGINE})
Expand Down
37 changes: 37 additions & 0 deletions fuzz/fuzz-datetime.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2026 Emweb bv, Herent, Belgium.
*
* See the LICENSE file for terms of use.
*/

#include <stdint.h>
#include <stddef.h>
#include <string>

#include "Wt/WString.h"
#include "Wt/WDate.h"
#include "Wt/WTime.h"
#include "Wt/WDateTime.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < 1)
return 0;

// First byte splits the remaining bytes into a format string and a value
// string, so both the format parser and the value parser get fuzzed.
std::size_t formatLen = data[0] % size;
std::string format(reinterpret_cast<const char*>(data + 1), formatLen);
std::string value(reinterpret_cast<const char*>(data + 1 + formatLen),
size - 1 - formatLen);

Wt::WString f = Wt::WString::fromUTF8(format);
Wt::WString v = Wt::WString::fromUTF8(value);

try { Wt::WDateTime::fromString(v, f); } catch (...) {}
try { Wt::WDate::fromString(v, f); } catch (...) {}
try { Wt::WTime::fromString(v, f); } catch (...) {}
try { Wt::WDateTime::fromString(v); } catch (...) {}

return 0;
}
Binary file added fuzz/fuzz-datetime_seed_corpus.zip
Binary file not shown.