mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-23 21:11:09 +01:00
- Do not override sin6_scope_id in LLA when it is already set to non-zero.
This fixes destination list in output of netstat -r. - Plug a memory leak. - Add RTM_VERSION check. - Minor style fixes.
This commit is contained in:
parent
f0e9dced5c
commit
0e798e1faa
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=266177
@ -586,8 +586,9 @@ p_rtable_sysctl(int fibnum, int af)
|
||||
mib[4] = NET_RT_DUMP;
|
||||
mib[5] = 0;
|
||||
mib[6] = fibnum;
|
||||
if (sysctl(mib, 7, NULL, &needed, NULL, 0) < 0) {
|
||||
err(1, "sysctl: net.route.0.%d.dump.%d estimate", af, fibnum);
|
||||
if (sysctl(mib, nitems(mib), NULL, &needed, NULL, 0) < 0) {
|
||||
err(EX_OSERR, "sysctl: net.route.0.%d.dump.%d estimate", af,
|
||||
fibnum);
|
||||
}
|
||||
|
||||
if ((buf = malloc(needed)) == 0) {
|
||||
@ -599,6 +600,8 @@ p_rtable_sysctl(int fibnum, int af)
|
||||
lim = buf + needed;
|
||||
for (next = buf; next < lim; next += rtm->rtm_msglen) {
|
||||
rtm = (struct rt_msghdr *)next;
|
||||
if (rtm->rtm_version != RTM_VERSION)
|
||||
continue;
|
||||
/*
|
||||
* Peek inside header to determine AF
|
||||
*/
|
||||
@ -611,6 +614,7 @@ p_rtable_sysctl(int fibnum, int af)
|
||||
}
|
||||
p_rtentry_sysctl(rtm);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -971,9 +975,9 @@ in6_fillscopeid(struct sockaddr_in6 *sa6)
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr) ||
|
||||
IN6_IS_ADDR_MC_NODELOCAL(&sa6->sin6_addr) ||
|
||||
IN6_IS_ADDR_MC_LINKLOCAL(&sa6->sin6_addr)) {
|
||||
/* XXX: override is ok? */
|
||||
sa6->sin6_scope_id =
|
||||
ntohs(*(u_int16_t *)&sa6->sin6_addr.s6_addr[2]);
|
||||
if (sa6->sin6_scope_id == 0)
|
||||
sa6->sin6_scope_id =
|
||||
ntohs(*(u_int16_t *)&sa6->sin6_addr.s6_addr[2]);
|
||||
sa6->sin6_addr.s6_addr[2] = sa6->sin6_addr.s6_addr[3] = 0;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user