summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-04-28 13:49:13 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-04-28 13:49:13 +0000
commit0038c3369dd66655dd155902da4283ca84dc9f36 (patch)
tree29b7aa1e84874ba8ca81c70fee8f9a5735156439 /usr.sbin
parent1e306917f833fec01ba6a48ed5d236ad1dc64841 (diff)
Be more careful when copying ifname from the struct sockaddr_dl.
OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/kroute.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 2680803b888..daac81ea272 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.123 2005/04/18 11:07:55 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.124 2005/04/28 13:49:12 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1308,9 +1308,12 @@ fetchifs(int ifindex)
if ((sa = rti_info[RTAX_IFP]) != NULL)
if (sa->sa_family == AF_LINK) {
sdl = (struct sockaddr_dl *)sa;
- if (sdl->sdl_nlen > 0)
+ if (sdl->sdl_nlen >= sizeof(kif->k.ifname))
strlcpy(kif->k.ifname, sdl->sdl_data,
sizeof(kif->k.ifname));
+ else if (sdl->sdl_nlen > 0)
+ strlcpy(kif->k.ifname, sdl->sdl_data,
+ sdl->sdl_nlen + 1);
}
kif_insert(kif);