From: Roy Marples Date: Wed, 4 Mar 2020 15:07:24 +0000 (+0000) Subject: DHCP: Move the max frame length check X-Git-Tag: v9.0.0~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f00baabe6d6967b50598ad7a34e650ec4e960cf;p=thirdparty%2Fdhcpcd.git DHCP: Move the max frame length check --- diff --git a/src/dhcp.c b/src/dhcp.c index 0c96ea93..e7193379 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -3447,6 +3447,13 @@ dhcp_handlebootp(struct interface *ifp, struct bootp *bootp, size_t len, return; } + /* Unlikely, but appeases sanitizers. */ + if (len > FRAMELEN_MAX) { + logerrx("%s: packet exceeded frame length (%zu) from %s", + ifp->name, len, inet_ntoa(*from)); + return; + } + /* To make our IS_DHCP macro easy, ensure the vendor * area has at least 4 octets. */ v = len - offsetof(struct bootp, vend); @@ -3556,15 +3563,6 @@ dhcp_recvmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg) struct interface *ifp; const struct dhcp_state *state; -#ifdef PRIVSEP - /* Unlikely, but appeases sanitizers. */ - if (iov->iov_len > FRAMELEN_MAX) { - errno = ENOBUFS; - logerr(__func__); - return; - } -#endif - ifp = if_findifpfromcmsg(ctx, msg, NULL); if (ifp == NULL) { logerr(__func__);