diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3f5c177 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +--- +# vi: ts=2 sw=2 et: + +name: Build test +on: [pull_request] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-20.04 + concurrency: + group: ${{ github.workflow }}-${{ toJSON(matrix.env) }}-${{ github.ref }} + cancel-in-progress: true + strategy: + fail-fast: false + matrix: + env: + - { + TYPE: "default", + CFLAGS: "-Werror -Wextra" + } + - { + TYPE: "asan+ubsan", + CFLAGS: "-Werror -Wextra -fsanitize=address,undefined", + ASAN_OPTIONS: "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:abort_on_error=1", + UBSAN_OPTIONS: "print_stacktrace=1:print_summary=1:halt_on_error=1" + } + env: ${{ matrix.env }} + name: ${{ matrix.env.TYPE }} + steps: + - name: Repository checkout + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt -y update + sudo apt -y install gcc libglib2.0-dev libffi-dev make + + - name: Build + run: | + make -C src + ./src/dfuzzer -V + ./src/dfuzzer -s -l + sudo make -C src install + + - name: Test + run: | + # Test as an unprivileged user + dfuzzer -v -n org.freedesktop.systemd1 + # Test as root + sudo dfuzzer -v -n org.freedesktop.systemd1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54b46c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.sw* +*.o +tags +src/dfuzzer +src/makefile.dep diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..09b3e48 --- /dev/null +++ b/.vimrc @@ -0,0 +1,3 @@ +set noet +set tabstop=4 +set shiftwidth=4 diff --git a/src/Makefile b/src/Makefile index f7b62f8..83f0c26 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,12 +3,12 @@ # Copyright(C) 2014, 2015, Red Hat, Inc., Matus Marhefka #============================================================================== -CC=gcc -CFLAGS=-Wall -w -O2 -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 `pkg-config --cflags --libs gio-2.0 libffi` -g -OBJ=dfuzzer.o introspection.o fuzz.o rand.o -TARGET=dfuzzer +CC ?= gcc +CFLAGS += -Wall -w -O2 -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 `pkg-config --cflags --libs gio-2.0 libffi` -g +OBJ = dfuzzer.o introspection.o fuzz.o rand.o +TARGET = dfuzzer all: dfuzzer -.PHONY: doc man clean +.PHONY: doc man clean install makefile.dep: @@ -16,6 +16,11 @@ makefile.dep: $(TARGET): $(OBJ) $(CC) $(OBJ) $(CFLAGS) -o $(TARGET) +install: $(TARGET) man + install -pm 0755 $(TARGET) /usr/bin/$(TARGET) + install -pm 0644 dfuzzer.conf /etc/dfuzzer.conf + install -pm 0644 ../man/dfuzzer.1.gz /usr/share/man/man1/dfuzzer.1.gz + doc: doxygen doxyfile