git: 6894d9a74aa1 - stable/14 - netmap: Don't assume that user-provided strings are nul-terminated

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a67dc83.25644.787619eb__12802.296276071$1785191578$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=6894d9a74aa1c588d77c131568bd87571bd15316

commit 6894d9a74aa1c588d77c131568bd87571bd15316
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-08 17:11:05 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-07-27 14:05:07 +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.