DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] lib: do not call memcpy with sz zero and null pointer
@ 2022-09-07 15:05 Henning Schild
  2022-09-21 13:06 ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Henning Schild @ 2022-09-07 15:05 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev, Henning Schild

There is no point in such a call and UBSan complains about a call to
memcpy with a null pointer as second arg.

When building with -Db_sanitize=undefined, Clang gives the following
warning
../lib/bpf/bpf_load.c:37:20: runtime error: null pointer passed as
	argument 2, which is declared to never be null

A check of the sz before calling memcpy fixes that.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 lib/bpf/bpf_load.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/bpf/bpf_load.c b/lib/bpf/bpf_load.c
index 0c4ac7be6c55..48d3d80ac3e3 100644
--- a/lib/bpf/bpf_load.c
+++ b/lib/bpf/bpf_load.c
@@ -34,7 +34,8 @@ bpf_load(const struct rte_bpf_prm *prm)
 
 	memcpy(&bpf->prm, prm, sizeof(bpf->prm));
 
-	memcpy(buf + bsz, prm->xsym, xsz);
+	if (xsz)
+		memcpy(buf + bsz, prm->xsym, xsz);
 	memcpy(buf + bsz + xsz, prm->ins, insz);
 
 	bpf->prm.xsym = (void *)(buf + bsz);
-- 
2.35.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-21 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 15:05 [PATCH] lib: do not call memcpy with sz zero and null pointer Henning Schild
2022-09-21 13:06 ` Thomas Monjalon
2022-09-21 13:57   ` Henning Schild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).