From 93e955b57c1cde900584e6b8d13b254ff92b9d48 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Fri, 31 May 2024 10:16:25 +0200 Subject: [PATCH 1/3] ci/sanitizer: add undefined behavior sanitizer --- .github/workflows/sanitizers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 0f744b951..5acf6fe44 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -15,11 +15,11 @@ jobs: strategy: matrix: os: [ubuntu-22.04] - sanitizer: [thread, address] + sanitizer: [thread, address, undefined] env: CC: clang-17 CMAKE_GENERATOR: Ninja - CFLAGS: "-fsanitize=${{ matrix.sanitizer }}" + CFLAGS: "-fsanitize=${{ matrix.sanitizer }} -fno-sanitize-recover=all -fno-sanitize=function" ASAN_OPTIONS: fast_unwind_on_malloc=0 steps: From 7cafc6f76e7bcb43ce9dcb5d1c7ed3cd4096b26a Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Fri, 31 May 2024 12:03:49 +0200 Subject: [PATCH 2/3] test/vidconv: fix undefined null memcmp --- test/vidconv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vidconv.c b/test/vidconv.c index c34a88125..d4bf8bf01 100644 --- a/test/vidconv.c +++ b/test/vidconv.c @@ -348,6 +348,9 @@ int test_vidconv_pixel_formats(void) size_t size = test->dst_planev[p].sz; + if (!test->dst_planev[p].data) + continue; + TEST_MEMCMP(test->dst_planev[p].data, test->dst_planev[p].sz, fdst->data[p], From 69746a99174a5d48095922b8d510003e0f2fb601 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Fri, 31 May 2024 12:05:37 +0200 Subject: [PATCH 3/3] test/http: avoid NULL pointer STRCMP (undefined behavior) --- test/http.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/http.c b/test/http.c index a8417e438..2da471cee 100644 --- a/test/http.c +++ b/test/http.c @@ -344,9 +344,9 @@ static void http_resp_handler(int err, const struct http_msg *msg, void *arg) /* verify HTTP response */ TEST_STRCMP("1.1", 3, msg->ver.p, msg->ver.l); - TEST_STRCMP("", 0, msg->met.p, msg->met.l); - TEST_STRCMP("", 0, msg->path.p, msg->path.l); - TEST_STRCMP("", 0, msg->prm.p, msg->prm.l); + TEST_ASSERT(!msg->met.p); + TEST_ASSERT(!msg->path.p); + TEST_ASSERT(!msg->prm.p); TEST_EQUALS(200, msg->scode); TEST_STRCMP("OK", 2, msg->reason.p, msg->reason.l); TEST_EQUALS(t->clen, msg->clen);