diff --git a/.github/workflows/build-and-run-examples.yml b/.github/workflows/build-and-run-examples.yml index 2b59d66ae..e5d2746d3 100644 --- a/.github/workflows/build-and-run-examples.yml +++ b/.github/workflows/build-and-run-examples.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: transport: [ 'tcp', 'shm', 'dma' ] + asan: [ 'ASAN=1', 'ASAN=0' ] runs-on: ubuntu-latest timeout-minutes: 5 @@ -28,16 +29,16 @@ jobs: - name: Build POSIX server run: | if [ "${{ matrix.transport }}" = "dma" ]; then - cd examples/posix/wh_posix_server && DMA=1 make -j WOLFSSL_DIR=../../../wolfssl + cd examples/posix/wh_posix_server && ${{ matrix.asan }} DMA=1 make -j WOLFSSL_DIR=../../../wolfssl else - cd examples/posix/wh_posix_server && make -j WOLFSSL_DIR=../../../wolfssl + cd examples/posix/wh_posix_server && ${{ matrix.asan }} make -j WOLFSSL_DIR=../../../wolfssl fi - name: Build POSIX client run: | if [ "${{ matrix.transport }}" = "dma" ]; then - cd examples/posix/wh_posix_client && DMA=1 make -j WOLFSSL_DIR=../../../wolfssl + cd examples/posix/wh_posix_client && ${{ matrix.asan }} DMA=1 make -j WOLFSSL_DIR=../../../wolfssl else - cd examples/posix/wh_posix_client && make -j WOLFSSL_DIR=../../../wolfssl + cd examples/posix/wh_posix_client && ${{ matrix.asan }} make -j WOLFSSL_DIR=../../../wolfssl fi # Start the server in the background diff --git a/examples/posix/wh_posix_client/Makefile b/examples/posix/wh_posix_client/Makefile index 20b125ee9..33c8a8101 100644 --- a/examples/posix/wh_posix_client/Makefile +++ b/examples/posix/wh_posix_client/Makefile @@ -75,6 +75,12 @@ ifeq ($(DEBUG),1) LDFLAGS += $(DBGFLAGS) endif +# Add address sanitizer option +ifeq ($(ASAN),1) + CFLAGS += -fsanitize=address + LDFLAGS += -fsanitize=address +endif + ## Source files # Assembly source files SRC_ASM += diff --git a/examples/posix/wh_posix_server/Makefile b/examples/posix/wh_posix_server/Makefile index 4b8787210..7765e46e7 100644 --- a/examples/posix/wh_posix_server/Makefile +++ b/examples/posix/wh_posix_server/Makefile @@ -66,6 +66,12 @@ ifeq ($(DEBUG),1) LDFLAGS += $(DBGFLAGS) endif +# Add address sanitizer option +ifeq ($(ASAN),1) + CFLAGS += -fsanitize=address + LDFLAGS += -fsanitize=address +endif + # Support a SHE-capable build ifeq ($(SHE),1) CFLAGS += -DWOLFHSM_CFG_SHE_EXTENSION