Files
acceptance-tests
data
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
cmake
docs
include
lib
test
BlocksRuntime
asan
builtins
cfi
dfsan
esan
fuzzer
unit
AFLDriverTest.cpp
AbsNegAndConstant64Test.cpp
AbsNegAndConstantTest.cpp
AccumulateAllocationsTest.cpp
BadStrcmpTest.cpp
BogusInitializeTest.cpp
BufferOverflowOnInput.cpp
CMakeLists.txt
CallerCalleeTest.cpp
CleanseTest.cpp
CounterTest.cpp
CustomCrossOverAndMutateTest.cpp
CustomCrossOverTest.cpp
CustomMutatorTest.cpp
CxxStringEqTest.cpp
DSO1.cpp
DSO2.cpp
DSOTestExtra.cpp
DSOTestMain.cpp
DeepRecursionTest.cpp
DivTest.cpp
EmptyTest.cpp
EquivalenceATest.cpp
EquivalenceBTest.cpp
FlagsTest.cpp
FourIndependentBranchesTest.cpp
FullCoverageSetTest.cpp
GcSectionsTest.cpp
InitializeTest.cpp
LargeTest.cpp
LeakTest.cpp
LeakTimeoutTest.cpp
LoadTest.cpp
Memcmp64BytesTest.cpp
MemcmpTest.cpp
NotinstrumentedTest.cpp
NthRunCrashTest.cpp
NullDerefOnEmptyTest.cpp
NullDerefTest.cpp
OneHugeAllocTest.cpp
OutOfMemorySingleLargeMallocTest.cpp
OutOfMemoryTest.cpp
OverwriteInputTest.cpp
PrintFuncTest.cpp
RepeatedBytesTest.cpp
RepeatedMemcmp.cpp
ShrinkControlFlowSimpleTest.cpp
ShrinkControlFlowTest.cpp
ShrinkValueProfileTest.cpp
SignedIntOverflowTest.cpp
SimpleCmpTest.cpp
SimpleDictionaryTest.cpp
SimpleHashTest.cpp
SimpleTest.cpp
SimpleThreadedTest.cpp
SingleByteInputTest.cpp
SingleMemcmpTest.cpp
SingleStrcmpTest.cpp
SingleStrncmpTest.cpp
SleepOneSecondTest.cpp
SpamyTest.cpp
StrcmpTest.cpp
StrncmpOOBTest.cpp
StrncmpTest.cpp
StrstrTest.cpp
SwapCmpTest.cpp
Switch2Test.cpp
SwitchTest.cpp
TableLookupTest.cpp
ThreadedLeakTest.cpp
ThreadedTest.cpp
TimeoutEmptyTest.cpp
TimeoutTest.cpp
TraceMallocTest.cpp
TraceMallocThreadedTest.cpp
TwoDifferentBugsTest.cpp
afl-driver-extra-stats.test
afl-driver-stderr.test
afl-driver.test
bad-strcmp.test
caller-callee.test
cleanse.test
coverage.test
cxxstring.test
deep-recursion.test
dict1.txt
disable-leaks.test
dump_coverage.test
equivalence-signals.test
equivalence.test
exit-report.test
exit_on_src_pos.test
extra-counters.test
fprofile-instr-generate.test
fuzzer-customcrossover.test
fuzzer-customcrossoverandmutate.test
fuzzer-custommutator.test
fuzzer-dict.test
fuzzer-dirs.test
fuzzer-fdmask.test
fuzzer-finalstats.test
fuzzer-flags.test
fuzzer-leak.test
fuzzer-oom-with-profile.test
fuzzer-oom.test
fuzzer-printcovpcs.test
fuzzer-runs.test
fuzzer-seed.test
fuzzer-segv.test
fuzzer-singleinputs.test
fuzzer-threaded.test
fuzzer-timeout.test
fuzzer-ubsan.test
fuzzer.test
gc-sections.test
hi.txt
inline-8bit-counters.test
lit.cfg
lit.site.cfg.in
max-number-of-runs.test
memcmp.test
memcmp64.test
merge-control-file.test
merge-posix.test
merge-sigusr.test
merge-summary.test
merge.test
minimize_crash.test
minimize_two_crashes.test
overwrite-input.test
print-func.test
recommended-dictionary.test
reduce_inputs.test
repeated-bytes.test
shrink.test
sigusr.test
simple-cmp.test
standalone.test
strcmp.test
strncmp.test
strstr.test
swap-cmp.test
trace-malloc-2.test
trace-malloc-threaded.test
trace-malloc-unbalanced.test
trace-malloc.test
trace-pc.test
ulimit.test
value-profile-cmp.test
value-profile-cmp2.test
value-profile-cmp3.test
value-profile-cmp4.test
value-profile-div.test
value-profile-load.test
value-profile-mem.test
value-profile-set.test
value-profile-strcmp.test
value-profile-strncmp.test
value-profile-switch.test
hwasan
interception
lsan
msan
profile
safestack
sanitizer_common
scudo
tsan
ubsan
ubsan_minimal
xray
CMakeLists.txt
lit.common.cfg
lit.common.configured.in
unittests
www
.arcconfig
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/compiler-rt/test/fuzzer/SwapCmpTest.cpp

36 lines
898 B
C++
Raw Normal View History

// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// The fuzzer must find several constants with swapped bytes.
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size < 14) return 0;
uint64_t x = 0;
uint32_t y = 0;
uint16_t z = 0;
memcpy(&x, Data, sizeof(x));
memcpy(&y, Data + Size / 2, sizeof(y));
memcpy(&z, Data + Size - sizeof(z), sizeof(z));
x = __builtin_bswap64(x);
y = __builtin_bswap32(y);
z = __builtin_bswap16(z);
const bool k32bit = sizeof(void*) == 4;
if ((k32bit || x == 0x46555A5A5A5A5546ULL) &&
z == 0x4F4B &&
y == 0x66757A7A &&
true
) {
if (Data[Size - 3] == 'z') {
fprintf(stderr, "BINGO; Found the target\n");
exit(1);
}
}
return 0;
}