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 2, 2025
1 parent 3dbdaef commit 0bbde4d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/mayhem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
fail-fast: false
matrix:
mayhemfile:
- mayhem/Mayhemfile
- mayhem/Mayhemfile_logging
- mayhem/Mayhemfile_hello

steps:
- uses: actions/checkout@v2
Expand Down
18 changes: 18 additions & 0 deletions mayhem/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@ RUN gcc -L/opt/ffmpeg/lib -I/opt/ffmpeg/include/ /files/0_hello_world.c \
-lavcodec -lavformat -lavfilter -lavdevice -lswresample -lswscale -lavutil \
-o /files/build/hello

RUN apt remove --purge --auto-remove cmake
RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y software-properties-common lsb-release && \
apt clean all
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y wget
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
RUN apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
RUN apt update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y cmake

WORKDIR /files/build
RUN cmake .. -DFFMPEG_DEV_ROOT=/opt/ffmpeg/
RUN make

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y clang
RUN clang++ /files/mayhem/fuzz_logging.cpp -fsanitize=fuzzer,address -L /files/build/lib/ -lvideo_debug -o /fuzz

FROM ubuntu:20.04 as package
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libavcodec-dev libavformat-dev libavutil-dev
COPY --from=builder /files/build/hello /
COPY --from=builder /fuzz /fuzz_logging
File renamed without changes.
6 changes: 6 additions & 0 deletions mayhem/Mayhemfile_logging
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project: ffmpeg-libav-tutorial
target: logging

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

#include <fuzzer/FuzzedDataProvider.h>

extern "C" void logging(const char *fmt, ...);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FuzzedDataProvider provider(data, size);
std::string str = provider.ConsumeRandomLengthString(1000);
const char* cstr = str.c_str();
logging(cstr);

return 0;
}

0 comments on commit 0bbde4d

Please sign in to comment.