Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 May 2021 17:09:34 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ad22ba2b9f3b - main - if: Remove unnecessary validation in the SIOCSIFNAME handler
Message-ID:  <202105121709.14CH9Yf5031751@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

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

commit ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-12 14:05:37 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-12 16:52:06 +0000

    if: Remove unnecessary validation in the SIOCSIFNAME handler
    
    A successful copyinstr() call guarantees that the returned string is
    nul-terminated.  Furthermore, the removed check would harmlessly compare
    an uninitialized byte with '\0' if the new name is shorter than
    IFNAMESIZ - 1.
    
    Reported by:    KMSAN
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 sys/net/if.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index e18ed3e275ac..f615d82636be 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2653,11 +2653,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
 			return (error);
 		if (new_name[0] == '\0')
 			return (EINVAL);
-		if (new_name[IFNAMSIZ-1] != '\0') {
-			new_name[IFNAMSIZ-1] = '\0';
-			if (strlen(new_name) == IFNAMSIZ-1)
-				return (EINVAL);
-		}
 		if (strcmp(new_name, ifp->if_xname) == 0)
 			break;
 		if (ifunit(new_name) != NULL)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105121709.14CH9Yf5031751>