summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2016-11-30 01:17:02 +0000
committerbrooks <brooks@FreeBSD.org>2016-11-30 01:17:02 +0000
commitf9912752d5f0359cb887482e286b10ab334bb8ce (patch)
tree96a0a0175e9f8bb3f0696ecea989c3d6c20b0dfc /sbin/dhclient
parentb646b68fbb596474a247384def9dad376176ada6 (diff)
downloadFreeBSD-src-f9912752d5f0359cb887482e286b10ab334bb8ce.zip
FreeBSD-src-f9912752d5f0359cb887482e286b10ab334bb8ce.tar.gz
MFC r309027:
Allocate a struct ifreq rather than using a (wrong) computed size for the BIOCSETIF ioctl. The kernel always copies an entire struct ifreq and IPv4 addresses will always fit in an ifreq. On systems with pointers larger than 64-bits, the computed size will be less than the size of struct ifreq, potentially resulting in the kernel attempting to copyin memory from outside the allocation. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8445
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dispatch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 3ee0cf6..3317ceb 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -105,8 +105,8 @@ discover_interfaces(struct interface_info *iface)
if (foo.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
continue;
if (!iface->ifp) {
- int len = IFNAMSIZ + ifa->ifa_addr->sa_len;
- if ((tif = malloc(len)) == NULL)
+ if ((tif = calloc(1, sizeof(struct ifreq)))
+ == NULL)
error("no space to remember ifp");
strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
memcpy(&tif->ifr_addr, ifa->ifa_addr,
OpenPOWER on IntegriCloud