From: Roy Marples Date: Tue, 18 Nov 2014 10:51:00 +0000 (+0000) Subject: If we don't have a hardware address, fallback to creating X-Git-Tag: v6.6.3~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efd2409a85ff0b64154a83cad1041388a82c5f96;p=thirdparty%2Fdhcpcd.git If we don't have a hardware address, fallback to creating a default IAID from the interface name and index as we used to. --- diff --git a/dhcpcd.c b/dhcpcd.c index 2df7f7f9..d6ac4258 100644 --- 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; }