summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-05-04 14:29:28 +0100
committerRoy Marples <roy@marples.name>2019-05-04 14:29:28 +0100
commit146b91ecb30687f438d1368c171c7f86eaa56ea6 (patch)
tree68388fe177ac4309504322db354babbc057ce47c
parent87baa737443916f11f55b8d42c5ddfd25694e540 (diff)
BSD: Ensure we have enough of a RTM message to read it.
As not all are of equal size.
-rw-r--r--src/dhcpcd.c3
-rw-r--r--src/if-bsd.c6
-rw-r--r--src/if-sun.c4
3 files changed, 8 insertions, 5 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index 5907fbbe..67dc3d64 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -1081,8 +1081,7 @@ dhcpcd_handlelink(void *arg)
dhcpcd_linkoverflow(ctx);
return;
}
- if (errno != ENOTSUP)
- logerr(__func__);
+ logerr(__func__);
}
}
diff --git a/src/if-bsd.c b/src/if-bsd.c
index 5e7fc3b6..ada85740 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -1063,7 +1063,7 @@ if_rtm(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
return 0;
if (if_copyrt(ctx, &rt, rtm) == -1)
- return -1;
+ return errno == ENOTSUP ? 0 : -1;
#ifdef INET6
/*
@@ -1326,7 +1326,9 @@ if_handlelink(struct dhcpcd_ctx *ctx)
return -1;
if (len == 0)
return 0;
- if (len < rtm.hdr.rtm_msglen) {
+ if ((size_t)len < offsetof(struct rt_msghdr, rtm_index) ||
+ len < rtm.hdr.rtm_msglen)
+ {
errno = EINVAL;
return -1;
}
diff --git a/src/if-sun.c b/src/if-sun.c
index 2a8728da..f680d666 100644
--- a/src/if-sun.c
+++ b/src/if-sun.c
@@ -1078,7 +1078,9 @@ if_handlelink(struct dhcpcd_ctx *ctx)
return -1;
if (len == 0)
return 0;
- if (len < rtm.hdr.rtm_msglen) {
+ if ((size_t)len < offsetof(struct rt_msghdr, rtm_index) ||
+ len < rtm.hdr.rtm_msglen)
+ {
errno = EINVAL;
return -1;
}