summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-11-18 10:51:00 +0000
committerRoy Marples <roy@marples.name>2014-11-18 10:51:00 +0000
commitefd2409a85ff0b64154a83cad1041388a82c5f96 (patch)
tree35f203a52e36252df542dd980099a25821b43cf9 /dhcpcd.c
parent04d57dc51c4eaf389ef3596df23ee19122d3d52c (diff)
downloaddhcpcd-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.c29
1 files changed, 17 insertions, 12 deletions
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;
}