mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-13 08:54:59 +00:00
[libFuzzer] honour -only_ascii=1 when reading the initial corpus. Also, remove ugly #ifdef
llvm-svn: 246689
This commit is contained in:
parent
2355899d99
commit
9c0479fa99
@ -53,6 +53,7 @@ void ComputeSHA1(const uint8_t *Data, size_t Len, uint8_t *Out);
|
||||
// Changes U to contain only ASCII (isprint+isspace) characters.
|
||||
// Returns true iff U has been changed.
|
||||
bool ToASCII(Unit &U);
|
||||
bool IsASCII(const Unit &U);
|
||||
|
||||
int NumberOfCpuCores();
|
||||
|
||||
|
@ -136,6 +136,8 @@ void Fuzzer::ShuffleAndMinimize() {
|
||||
U.clear();
|
||||
size_t Last = std::min(First + Options.MaxLen, C.size());
|
||||
U.insert(U.begin(), C.begin() + First, C.begin() + Last);
|
||||
if (Options.OnlyASCII)
|
||||
ToASCII(U);
|
||||
size_t NewCoverage = RunOne(U);
|
||||
if (NewCoverage) {
|
||||
MaxCov = NewCoverage;
|
||||
@ -256,11 +258,7 @@ void Fuzzer::WriteToOutputCorpus(const Unit &U) {
|
||||
WriteToFile(U, Path);
|
||||
if (Options.Verbosity >= 2)
|
||||
Printf("Written to %s\n", Path.c_str());
|
||||
#ifdef DEBUG
|
||||
if (Options.OnlyASCII)
|
||||
for (auto X : U)
|
||||
assert(isprint(X) || isspace(X));
|
||||
#endif
|
||||
assert(!Options.OnlyASCII || IsASCII(U));
|
||||
}
|
||||
|
||||
void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {
|
||||
|
@ -86,4 +86,10 @@ bool ToASCII(Unit &U) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
bool IsASCII(const Unit &U) {
|
||||
for (auto X : U)
|
||||
if (!(isprint(X) || isspace(X))) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace fuzzer
|
||||
|
Loading…
x
Reference in New Issue
Block a user