When handling SIOCSIFNAME ensure that the new interface name is NUL

terminated.  Reject the rename attempt if the name is too long.

MFC after:	1 week
This commit is contained in:
Don Lewis 2016-05-15 21:37:36 +00:00
parent 565e7fd3bc
commit 1ef3d54d20
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299865

View File

@ -2375,6 +2375,11 @@ 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 (ifunit(new_name) != NULL)
return (EEXIST);