diff options
| author | Roy Marples <roy@marples.name> | 2014-11-18 10:51:00 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2014-11-18 10:51:00 +0000 |
| commit | efd2409a85ff0b64154a83cad1041388a82c5f96 (patch) | |
| tree | 35f203a52e36252df542dd980099a25821b43cf9 /dhcpcd.c | |
| parent | 04d57dc51c4eaf389ef3596df23ee19122d3d52c (diff) | |
| download | dhcpcd-efd2409a85ff0b64154a83cad1041388a82c5f96.tar.xz | |
If we don't have a hardware address, fallback to creating
a default IAID from the interface name and index as we used to.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -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; } |
