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 Jan 14, 2025
1 parent ab10a94 commit ae3201f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 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_compare
- mayhem/Mayhemfile_pbf-decoder

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

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake clang

COPY . /repo
WORKDIR /repo/build
RUN cmake ..
RUN make -j8
RUN clang++ /repo/mayhem/fuzz_compare.cpp -fsanitize=fuzzer,address -I /repo/include/protozero/ -o /fuzz

FROM ubuntu:22.04 as package
COPY --from=builder /repo/build/tools/pbf-decoder /
COPY --from=builder /fuzz /fuzz_compare
6 changes: 6 additions & 0 deletions mayhem/Mayhemfile_compare
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project: protozero
target: compare

cmds:
- cmd: /fuzz_compare
libfuzzer: true
File renamed without changes.
19 changes: 19 additions & 0 deletions mayhem/fuzz_compare.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdint.h>
#include <stdio.h>
#include <climits>

#include <fuzzer/FuzzedDataProvider.h>
#include "data_view.hpp"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FuzzedDataProvider provider(data, size);
std::string str1 = provider.ConsumeRandomLengthString();
std::string str2 = provider.ConsumeRandomLengthString();
protozero::data_view dv1(str1);
protozero::data_view dv2(str2);

dv1.compare(dv2);

return 0;
}

0 comments on commit ae3201f

Please sign in to comment.