Skip to content

Commit

Permalink
enable chrono fuzzing for non-negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldreik committed May 29, 2019
1 parent de3555c commit c8a028f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(FMT_FUZZ_LDFLAGS "" CACHE STRING "LDFLAGS for the fuzz targets")

#find all fuzzers.
set(SOURCES
#chrono_duration.cpp # this triggers integer overflows I yet not know how to fix
chrono_duration.cpp # this triggers integer overflows I yet not know how to fix
named_arg.cpp
one_arg.cpp
sprintf.cpp
Expand Down
8 changes: 8 additions & 0 deletions fuzzing/chrono_duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdexcept>
#include <type_traits>
#include <vector>
#include <limits>

#include <fmt/chrono.h>

Expand All @@ -29,6 +30,13 @@ template <typename Item> void doit(const uint8_t* Data, std::size_t Size) {
Data += N;
Size -= N;

if(std::is_floating_point<Item>::value || std::numeric_limits<Item>::is_signed) {
if(item<0) {
//avoid problems with negative numbers until https://github.com/fmtlib/fmt/issues/1178 is solved
return;
}
}

// allocates as tight as possible, making it easier to catch buffer overruns
// also, make it null terminated.
std::vector<char> buf(Size + 1);
Expand Down

0 comments on commit c8a028f

Please sign in to comment.