mirror of
https://github.com/status-im/nim-drchaos.git
synced 2025-02-22 07:38:18 +00:00
v0.1.1
This commit is contained in:
parent
a4cbf3e6c6
commit
72664f3d7e
@ -1,6 +1,6 @@
|
|||||||
mode = ScriptMode.Verbose
|
mode = ScriptMode.Verbose
|
||||||
|
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
author = "Dr. Chaos Team"
|
author = "Dr. Chaos Team"
|
||||||
description = "A powerful and easy-to-use fuzzing framework in Nim for C/C++/Obj-C targets"
|
description = "A powerful and easy-to-use fuzzing framework in Nim for C/C++/Obj-C targets"
|
||||||
license = "Apache License 2.0"
|
license = "Apache License 2.0"
|
||||||
|
@ -11,9 +11,6 @@ when (NimMajor, NimMinor, NimPatch) < (1, 7, 1):
|
|||||||
result = cast[T](r.next shr (sizeof(uint64) - sizeof(T))*8)
|
result = cast[T](r.next shr (sizeof(uint64) - sizeof(T))*8)
|
||||||
|
|
||||||
when not defined(fuzzerStandalone):
|
when not defined(fuzzerStandalone):
|
||||||
proc LLVMFuzzerInitialize(): cint {.exportc.} =
|
|
||||||
{.emit: "N_CDECL(void, NimMain)(void); NimMain();".}
|
|
||||||
|
|
||||||
proc mutate(data: ptr UncheckedArray[byte], len, maxLen: int): int {.
|
proc mutate(data: ptr UncheckedArray[byte], len, maxLen: int): int {.
|
||||||
importc: "LLVMFuzzerMutate".}
|
importc: "LLVMFuzzerMutate".}
|
||||||
|
|
||||||
@ -525,12 +522,18 @@ proc runPostProcessor*[S, T](x: var array[S, T], depth: int; r: var Rand) =
|
|||||||
for i in low(x)..high(x):
|
for i in low(x)..high(x):
|
||||||
runPostProcessor(x[i], depth-1, r)
|
runPostProcessor(x[i], depth-1, r)
|
||||||
|
|
||||||
proc myMutator[T](x: var T; sizeIncreaseHint: Natural; r: var Rand) {.nimcall.} =
|
proc myMutator*[T](x: var T; sizeIncreaseHint: Natural; r: var Rand) {.nimcall.} =
|
||||||
runMutator(x, sizeIncreaseHint, true, r)
|
runMutator(x, sizeIncreaseHint, true, r)
|
||||||
when T is PostProcessTypes:
|
when T is PostProcessTypes:
|
||||||
runPostProcessor(x, MaxInitializeDepth, r)
|
runPostProcessor(x, MaxInitializeDepth, r)
|
||||||
|
|
||||||
template mutatorImpl(target, mutator, typ: untyped) =
|
template initImpl*() =
|
||||||
|
proc NimMain() {.importc: "NimMain".}
|
||||||
|
|
||||||
|
proc LLVMFuzzerInitialize(): cint {.exportc.} =
|
||||||
|
NimMain()
|
||||||
|
|
||||||
|
template mutatorImpl*(target, mutator, typ: untyped) =
|
||||||
{.pragma: nocov, codegenDecl: "__attribute__((no_sanitize(\"coverage\"))) $# $#$#".}
|
{.pragma: nocov, codegenDecl: "__attribute__((no_sanitize(\"coverage\"))) $# $#$#".}
|
||||||
{.pragma: nosan, codegenDecl: "__attribute__((disable_sanitizer_instrumentation)) $# $#$#".}
|
{.pragma: nosan, codegenDecl: "__attribute__((disable_sanitizer_instrumentation)) $# $#$#".}
|
||||||
|
|
||||||
@ -598,6 +601,7 @@ template mutatorImpl(target, mutator, typ: untyped) =
|
|||||||
proc commonImpl(target, mutator: NimNode): NimNode =
|
proc commonImpl(target, mutator: NimNode): NimNode =
|
||||||
let typ = getTypeImpl(target).params[^1][1]
|
let typ = getTypeImpl(target).params[^1][1]
|
||||||
result = getAst(mutatorImpl(target, mutator, typ))
|
result = getAst(mutatorImpl(target, mutator, typ))
|
||||||
|
result.add getAst(initImpl())
|
||||||
|
|
||||||
macro defaultMutator*(target: proc) =
|
macro defaultMutator*(target: proc) =
|
||||||
## Implements the interface for running LibFuzzer's fuzzing loop, where func `target`'s
|
## Implements the interface for running LibFuzzer's fuzzing loop, where func `target`'s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user