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
This commit is contained in:
Mark Johnston 2021-05-12 10:05:37 -04:00
parent 06d1fd9f42
commit ad22ba2b9f

View File

@ -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)