1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-04 12:52:15 +00:00

Don't mis-match interface names in iface_Create()

Submitted by: Adrian Penisoara <ady@freebsd.ady.ro>
This commit is contained in:
Brian Somers 2000-06-19 21:43:48 +00:00
parent 72e9d2e8a2
commit 58a575135b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61830

View File

@ -95,7 +95,7 @@ struct iface *
iface_Create(const char *name)
{
int mib[6], s;
size_t needed;
size_t needed, namelen;
char *buf, *ptr, *end;
struct if_msghdr *ifm;
struct ifa_msghdr *ifam;
@ -140,13 +140,14 @@ iface_Create(const char *name)
ptr = buf;
end = buf + needed;
iface = NULL;
namelen = strlen(name);
while (ptr < end && iface == NULL) {
ifm = (struct if_msghdr *)ptr; /* On if_msghdr */
if (ifm->ifm_type != RTM_IFINFO)
break;
dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */
if (!strncmp(name, dl->sdl_data, dl->sdl_nlen)) {
if (dl->sdl_nlen == namelen && !strncmp(name, dl->sdl_data, namelen)) {
iface = (struct iface *)malloc(sizeof *iface);
if (iface == NULL) {
fprintf(stderr, "iface_Create: malloc: %s\n", strerror(errno));