From b4d4d27d61706666a33518bef1c057d535271bd9 Mon Sep 17 00:00:00 2001 From: Brian Poole Date: Mon, 26 Oct 2026 16:19:21 -0400 Subject: [PATCH] netmap_bdg: fix strlcpy len computation An instance of strncpy() was converted to strlcpy() without modifying the length parameter. strlcpy() will only copy up to len - 1 bytes so the final byte was being dropped. Now use the size of the destination buffer as the length then set '\0' at the appropriate offset. --- sys/dev/netmap/netmap_bdg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/netmap/netmap_bdg.c b/sys/dev/netmap/netmap_bdg.c index 51c7ee20b..4391d6659 100644 --- a/sys/dev/netmap/netmap_bdg.c +++ b/sys/dev/netmap/netmap_bdg.c @@ -215,7 +215,8 @@ nm_find_bridge(const char *name, int create, struct netmap_bdg_ops *ops) nm_prerr("failed to allocate hash table"); return NULL; } - strlcpy(b->bdg_basename, name, namelen); + strlcpy(b->bdg_basename, name, sizeof(b->bdg_basename)); + b->bdg_basename[namelen] = '\0'; b->bdg_namelen = namelen; b->bdg_active_ports = 0; for (i = 0; i < NM_BDG_MAXPORTS; i++)