From 827c2aabfa6dec620b0295dce5ab0951ad254d36 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 21 Feb 2022 19:59:02 +0100 Subject: [PATCH 1/4] ci: add a basic CI --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/build.yml 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 From fd5ad62d3e72a21d26cda7b7ff32bce2164a3507 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 21 Feb 2022 20:15:54 +0100 Subject: [PATCH 2/4] Makefile: allow overriding $CC/$CFLAGS --- src/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index f7b62f8..be4e99d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,10 +3,10 @@ # 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 From 480de125447dacc7776355312059a87e51427031 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 21 Feb 2022 20:32:31 +0100 Subject: [PATCH 3/4] Makefile: add an install target --- src/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index be4e99d..83f0c26 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ CFLAGS += -Wall -w -O2 -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer- 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 From 289f2907b0e0f87eea7578c60e7ce4c893beb613 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 22 Feb 2022 19:04:55 +0100 Subject: [PATCH 4/4] Add .gitignore and .vimrc --- .gitignore | 5 +++++ .vimrc | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .gitignore create mode 100644 .vimrc 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