Don't invoke scripts for INADDR_ANY or INADDR_BROADCAST addresses.
This commit is contained in:
parent
0dbee937df
commit
547a909ccc
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: ifwatchd.c,v 1.33 2016/09/21 21:07:29 roy Exp $ */
|
/* $NetBSD: ifwatchd.c,v 1.34 2016/09/29 13:36:30 roy Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
||||||
|
@ -374,17 +374,32 @@ invoke_script(const struct sockaddr *sa, const struct sockaddr *dest,
|
||||||
const char *script;
|
const char *script;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (sa != NULL && sa->sa_len == 0) {
|
if (sa != NULL) {
|
||||||
fprintf(stderr, "illegal socket address (sa_len == 0)\n");
|
if (sa->sa_len == 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"illegal socket address (sa_len == 0)\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sa != NULL && sa->sa_family == AF_INET6) {
|
switch (sa->sa_family) {
|
||||||
struct sockaddr_in6 sin6;
|
case AF_INET:
|
||||||
|
{
|
||||||
|
const struct sockaddr_in *sin;
|
||||||
|
|
||||||
memcpy(&sin6, (const struct sockaddr_in6 *)sa, sizeof (sin6));
|
sin = (const struct sockaddr_in *)sa;
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
|
if (sin->sin_addr.s_addr == INADDR_ANY ||
|
||||||
|
sin->sin_addr.s_addr == INADDR_BROADCAST)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case AF_INET6:
|
||||||
|
{
|
||||||
|
const struct sockaddr_in6 *sin6;
|
||||||
|
|
||||||
|
sin6 = (const struct sockaddr_in6 *)sa;
|
||||||
|
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addr[0] = daddr[0] = 0;
|
addr[0] = daddr[0] = 0;
|
||||||
ifname = if_indextoname(ifindex, ifname_buf);
|
ifname = if_indextoname(ifindex, ifname_buf);
|
||||||
|
|
Loading…
Reference in New Issue