diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-13 08:29:14 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-13 08:29:14 +0000 |
commit | 652c6562a6ba93d3bf2c24df96181cf5cefcab03 (patch) | |
tree | 3ca2a3dfecdfb8e4720810b50bfa46b64ab56d5f /usr.sbin | |
parent | 81f22f2232a4227a0010b884d1567c4b065df260 (diff) |
The NET_RT_IFLIST sysctl returns RTM_IFINFO and RTM_NEWADDR messages in
the buffer. While RTM_IFINFO starts with a struct if_msghdr RTM_NEWADDR
does not. In other words (struct sockaddr *)(next + sizeof(ifm)) is only
correct for RTM_IFINFO and not for RTM_NEWADDR. So move the ifm_type check
up else get_rtaddrs() would access memory outside of buf.
OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospfd/kroute.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c index 73804b7fd5f..ccd45c6a387 100644 --- a/usr.sbin/ospfd/kroute.c +++ b/usr.sbin/ospfd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.15 2005/04/16 21:48:21 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.16 2005/05/13 08:29:13 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -825,12 +825,12 @@ fetchifs(int ifindex) lim = buf + len; for (next = buf; next < lim; next += ifm.ifm_msglen) { memcpy(&ifm, next, sizeof(ifm)); - sa = (struct sockaddr *)(next + sizeof(ifm)); - get_rtaddrs(ifm.ifm_addrs, sa, rti_info); - if (ifm.ifm_type != RTM_IFINFO) continue; + sa = (struct sockaddr *)(next + sizeof(ifm)); + get_rtaddrs(ifm.ifm_addrs, sa, rti_info); + if ((kif = calloc(1, sizeof(struct kif_node))) == NULL) { log_warn("fetchifs"); free(buf); |