Skip to content

Commit

Permalink
drop workarounds fixed upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldreik committed Jun 9, 2019
1 parent e936829 commit 03cdd2e
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions test/fuzzing/chrono_duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,21 @@ void doit(const uint8_t* Data, std::size_t Size, const int scaling) {
//is likely interesting.
const auto Nfixed=std::max(sizeof(long double),sizeof(std::intmax_t));
const auto N = sizeof(Item);
static_assert(N<=Nfixed,"fixed size is too small");
static_assert(N<=Nfixed, "fixed size is too small");
if (Size <= Nfixed + 1) {
return;
}
static_assert(std::is_trivially_copyable<Item>::value,"Item must be blittable");
static_assert(std::is_trivially_copyable<Item>::value, "Item must be blittable");
Item item{};
std::memcpy(&item, Data, N);

//fast forward
Data += Nfixed;
Size -= Nfixed;

// see https://github.com/fmtlib/fmt/issues/1178
const bool github_1178_is_solved = true;
if (!github_1178_is_solved) {
if (std::is_floating_point<Item>::value ||
std::numeric_limits<Item>::is_signed) {
if (item < 0) {
return;
}
}
}

// Data is already allocated separately in libFuzzer so reading past
// the end will most likely be detected anyway

// see https://github.com/fmtlib/fmt/issues/1194
#define GITHUB_1194_IS_SOLVED 1
#if GITHUB_1194_IS_SOLVED
const auto formatstring=fmt::string_view((const char*)Data, Size);
#else
// needs a null terminator, so allocate separately
std::vector<char> buf(Size+1);
std::memcpy(buf.data(), Data, Size);
const auto formatstring=fmt::string_view(buf.data(), Size);
#endif



// doit_impl<Item,std::yocto>(buf.data(),item);
// doit_impl<Item,std::zepto>(buf.data(),item);
Expand Down

0 comments on commit 03cdd2e

Please sign in to comment.