git: 5af72e6ab368 - stable/15 - netmap: Don't assume that user-provided strings are nul-terminated

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a67ae2f.38e0f.a6e6f06__34112.7586712659$1785179765$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=5af72e6ab368e1765606ce9f3fcf1946bfd38bbc

commit 5af72e6ab368e1765606ce9f3fcf1946bfd38bbc
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-08 17:11:05 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-07-27 17:34:31 +0000

    netmap: Don't assume that user-provided strings are nul-terminated
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit e1ab35148dd425340a88a2acaf10b972cb119f8f)
---
 sys/dev/netmap/netmap_bdg.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/dev/netmap/netmap_bdg.c b/sys/dev/netmap/netmap_bdg.c
index bcb45f55d160..1fe5052448f8 100644
--- a/sys/dev/netmap/netmap_bdg.c
+++ b/sys/dev/netmap/netmap_bdg.c
@@ -1043,6 +1043,10 @@ netmap_bdg_config(struct nm_ifreq *nr)
 	struct nm_bridge *b;
 	int error = EINVAL;
 
+	if (strnlen(nr->nifr_name, sizeof(nr->nifr_name)) >=
+	    sizeof(nr->nifr_name))
+		return error;
+
 	NMG_LOCK();
 	b = nm_find_bridge(nr->nifr_name, 0, NULL);
 	if (!b) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.