]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Move the max frame length check
authorRoy Marples <roy@marples.name>
Wed, 4 Mar 2020 15:07:24 +0000 (15:07 +0000)
committerRoy Marples <roy@marples.name>
Wed, 4 Mar 2020 15:07:24 +0000 (15:07 +0000)
src/dhcp.c

index 0c96ea93cf409779432d8f2cf8d3462f04e64718..e719337957772faf4fac1ca20d090492febc7018 100644 (file)
@@ -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__);