From ea33e660211ea762e0ab4b820b500db1b0c91337 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 4 Jan 2023 20:15:31 -0500 Subject: [PATCH] [BugFix] Buffering.c NULL src for memcpy is UB -- ASAN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No clue if our implementation would suffer the same fate but the C standard states: Where an argument declared as size_t n specifies the length of the array for a function, n can have the value zero […] pointer arguments on such a call shall still have valid values, as described in 7.1.4. Change-Id: Iee0dd9c948c6ad4b0d96309053127ab11111f04c --- apps/buffering.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/buffering.c b/apps/buffering.c index 9743c9c319..81b861ccf1 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -416,7 +416,8 @@ add_handle(unsigned int flags, size_t data_size, const char *path, h->signaled = 0; /* Data can be waited for */ /* Save the provided path */ - memcpy(h->path, path, pathsize); + if (path) + memcpy(h->path, path, pathsize); /* Return the start of the data area */ *data_out = ringbuf_add(index, handlesize);