2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if_ioctl.c: (interface_list_ioctl) Use if_get_by_name_len.
* if_proc.c: (ifaddr_proc_ipv6) Increase size of ifname buffer to
avoid overflow.
* kernel_socket.c: (ifan_read) Use if_get_by_name_len.
* if.h: Fix comments to reflect that if_lookup_by_name and
if_get_by_name now require the argument strings to be NUL-terminated.
* if.c: (if_lookup_by_name) Compare using strcmp.
(if_get_by_name) Pass strlen(ifname) as 2nd arg to if_create.
diff --git a/lib/if.c b/lib/if.c
index a32cee0..dbf4f20 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -219,9 +219,7 @@
for (node = listhead (iflist); node; nextnode (node))
{
ifp = getdata (node);
- /* Change this to strcmp once improper uses of this function
- have been replaced with calls to if_lookup_by_name_len. */
- if (strncmp (name, ifp->name, sizeof ifp->name) == 0)
+ if (strcmp(name, ifp->name) == 0)
return ifp;
}
return NULL;
@@ -335,10 +333,8 @@
{
struct interface *ifp;
- /* Replace 2nd arg to if_create with strlen(name) once improper uses of
- this function have been replaced with calls to if_get_by_name_len. */
return ((ifp = if_lookup_by_name(name)) != NULL) ? ifp :
- if_create(name, INTERFACE_NAMSIZ);
+ if_create(name, strlen(name));
}
struct interface *