]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Fill chaddr if hwlen really is 16 bytes
authorRoy Marples <roy@marples.name>
Thu, 2 Jun 2022 05:36:18 +0000 (06:36 +0100)
committerRoy Marples <roy@marples.name>
Thu, 2 Jun 2022 05:36:18 +0000 (06:36 +0100)
This isn't normally a problem as ethernet is 6 bytes in length.
Spotted by Steve Noonan.

src/dhcp.c

index bfd4012739da8bdc5045139315ee60e710126364..2f221bc71d9d6059975340f7a3d6b5be60ec6597 100644 (file)
@@ -782,7 +782,7 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type)
 
        bootp->op = BOOTREQUEST;
        bootp->htype = (uint8_t)ifp->hwtype;
-       if (ifp->hwlen != 0 && ifp->hwlen < sizeof(bootp->chaddr)) {
+       if (ifp->hwlen != 0 && ifp->hwlen <= sizeof(bootp->chaddr)) {
                bootp->hlen = (uint8_t)ifp->hwlen;
                memcpy(&bootp->chaddr, &ifp->hwaddr, ifp->hwlen);
        }