[PATCH] D60008: Use binary write mode in WriteToFile function to avoid appended \r characters on Windows
tuktuk via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 30 11:21:23 PDT 2019
tuktuk added a comment.
There is a problem with that generic solution which is that nothing in it forces libfuzzer to generate multiple byte values and in my experiments the data I get is always very poorly distributed, so in practice it is not that generic.
I tried a fuzz target that would force libfuzzer to have at least one instance of every possible byte value, but libfuzzer wouldn't manage to generate appropriate data.
However I can confirm that the following fuzz target can be used to differentiate between pre-patch and patched versions following the (non-)reproducibility test we talked about:
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Tests preservation of crashing inputs when writing to disk.
#include <cstdint>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
static bool Found[256];
// Make sure Data is quite long
if (Size < 1000) {
return 0;
}
// Make sure Data has at least one '\n' byte value
// Checking that Data has all possible byte values would be more satisfying
// but libfuzzer doesn't seem powerful enough for this right now
for (size_t i = 0; i < 256; ++i) {
Found[i] = false;
}
for (size_t i = 0; i < Size; ++i) {
Found[Data[i]] = true;
}
if (!Found['\n']) {
return 0;
}
// Crash upon some hash value from Size and Data
// Reproducibility will only happen if hash value is the same
size_t Sum = Size;
for (size_t i = 0; i < Size; ++i) {
Sum += Data[i];
}
if (Sum % 100 == 19) {
__builtin_trap();
}
return 0;
}
I spent some time trying to understand llvm lit syntax but I couldn't produce a satisfying test file that I would be able to run from my Windows machine. Could you do this part? Thanks a lot.
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60008/new/
https://reviews.llvm.org/D60008
More information about the llvm-commits
mailing list