]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If we don't have a hardware address, fallback to creating
authorRoy Marples <roy@marples.name>
Tue, 18 Nov 2014 10:51:00 +0000 (10:51 +0000)
committerRoy Marples <roy@marples.name>
Tue, 18 Nov 2014 10:51:00 +0000 (10:51 +0000)
a default IAID from the interface name and index as we used to.

dhcpcd.c

index 2df7f7f927ec543e9b89cfb4fadb7a92fc46fba1..d6ac4258f80a0d886eb9656d4bdebe7fb8574e96 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -432,19 +432,24 @@ configure_interface1(struct interface *ifp)
                 * dhcpcd-6.1.0 and earlier used the interface name,
                 * falling back to interface index if name > 4.
                 */
-               memcpy(ifo->iaid, ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
-                   sizeof(ifo->iaid));
-#if 0
-               len = strlen(ifp->name);
-               if (len <= sizeof(ifo->iaid)) {
-                       memcpy(ifo->iaid, ifp->name, len);
-                       memset(ifo->iaid + len, 0, sizeof(ifo->iaid) - len);
-               } else {
-                       /* IAID is the same size as a uint32_t */
-                       len = htonl(ifp->index);
-                       memcpy(ifo->iaid, &len, sizeof(len));
+               if (ifp->hwlen >= sizeof(ifo->iaid))
+                       memcpy(ifo->iaid,
+                           ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
+                           sizeof(ifo->iaid));
+               else {
+                       uint32_t len;
+                       
+                       len = (uint32_t)strlen(ifp->name);
+                       if (len <= sizeof(ifo->iaid)) {
+                               memcpy(ifo->iaid, ifp->name, len);
+                               memset(ifo->iaid + len, 0,
+                                   sizeof(ifo->iaid) - len);
+                       } else {
+                               /* IAID is the same size as a uint32_t */
+                               len = htonl(ifp->index);
+                               memcpy(ifo->iaid, &len, sizeof(len));
+                       }
                }
-#endif
                ifo->options |= DHCPCD_IAID;
        }