aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/route/route.c19
-rw-r--r--sbin/routed/table.c9
2 files changed, 19 insertions, 9 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 97da81766c79..062fecd3cc3b 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1497,10 +1497,7 @@ rtmsg(int cmd, int flags, int fib)
#define NEXTADDR(w, u) \
if (rtm_addrs & (w)) { \
- l = (((struct sockaddr *)&(u))->sa_len == 0) ? \
- sizeof(long) : \
- 1 + ((((struct sockaddr *)&(u))->sa_len - 1) \
- | (sizeof(long) - 1)); \
+ l = SA_SIZE(&(u)); \
memmove(cp, (char *)&(u), l); \
cp += l; \
if (verbose) \
@@ -1564,7 +1561,8 @@ rtmsg(int cmd, int flags, int fib)
do {
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
} while (l > 0 && stop_read == 0 &&
- (rtm.rtm_seq != rtm_seq || rtm.rtm_pid != pid));
+ (rtm.rtm_type != RTM_GET || rtm.rtm_seq != rtm_seq ||
+ rtm.rtm_pid != pid));
if (stop_read != 0) {
warnx("read from routing socket timed out");
return (-1);
@@ -1706,10 +1704,13 @@ print_rtmsg(struct rt_msghdr *rtm, size_t msglen)
break;
default:
- printf("pid: %ld, seq %d, errno %d, flags:",
- (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
- printb(rtm->rtm_flags, routeflags);
- pmsg_common(rtm, msglen);
+ if (rtm->rtm_type <= RTM_RESOLVE) {
+ printf("pid: %ld, seq %d, errno %d, flags:",
+ (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
+ printb(rtm->rtm_flags, routeflags);
+ pmsg_common(rtm, msglen);
+ } else
+ printf("type: %u, len: %zu\n", rtm->rtm_type, msglen);
}
return;
diff --git a/sbin/routed/table.c b/sbin/routed/table.c
index ce2c18d392e2..fe719cd31d29 100644
--- a/sbin/routed/table.c
+++ b/sbin/routed/table.c
@@ -1233,6 +1233,15 @@ read_rt(void)
if (m.r.rtm.rtm_type <= RTM_CHANGE)
strp += sprintf(strp," from pid %d",m.r.rtm.rtm_pid);
+ /*
+ * Only messages that use the struct rt_msghdr format are
+ * allowed beyond this point.
+ */
+ if (m.r.rtm.rtm_type > RTM_RESOLVE) {
+ trace_act("ignore %s", str);
+ continue;
+ }
+
rt_xaddrs(&info, m.r.addrs, &m.r.addrs[RTAX_MAX],
m.r.rtm.rtm_addrs);