Skip to content

Commit

Permalink
Add harness
Browse files Browse the repository at this point in the history
  • Loading branch information
rnshah9 authored and ForAllSecure Mayhem Bot committed Oct 24, 2024
1 parent 0c77bdc commit e735921
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/mayhem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
fail-fast: false
matrix:
mayhemfile:
- mayhem/Mayhemfile
- mayhem/Mayhemfile_elf2nro
- mayhem/Mayhemfile_local_bswap64

steps:
- uses: actions/checkout@v3
Expand Down
10 changes: 7 additions & 3 deletions mayhem/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM --platform=linux/amd64 ubuntu:20.04 as builder
FROM --platform=linux/amd64 ubuntu:22.04 as builder

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential automake pkg-config libtool liblz4-dev libz-dev
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential automake pkg-config libtool liblz4-dev libz-dev clang

COPY . /repo
WORKDIR /repo
Expand All @@ -10,6 +10,10 @@ RUN ./configure --prefix=/install
RUN make -j8
RUN make install

FROM ubuntu:20.04 as package
WORKDIR /repo/src
RUN clang++ /repo/mayhem/fuzz_local_bswap64.cpp -fsanitize=fuzzer,address -o /fuzz -I /repo/src

FROM ubuntu:22.04 as package
COPY --from=builder /install /install
COPY --from=builder /repo/elf2nro /
COPY --from=builder /fuzz /fuzz_local_bswap64
File renamed without changes.
5 changes: 5 additions & 0 deletions mayhem/Mayhemfile_local_bswap64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project: switch-tools
target: local-bswap64

cmds:
- cmd: /fuzz_local_bswap64
14 changes: 14 additions & 0 deletions mayhem/fuzz_local_bswap64.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdint.h>
#include <stdio.h>
#include <climits>

#include "types.h"
#include <fuzzer/FuzzedDataProvider.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FuzzedDataProvider provider(data, size);
uint64_t x = provider.ConsumeIntegral<uint64_t>();
__local_bswap64(x);
return 0;
}

0 comments on commit e735921

Please sign in to comment.