} else {
/* Nope, so mark it as-is */
len = strlen(options->clientid) + 1;
- iface->clientid = xmalloc(len + 1);
+ iface->clientid = xmalloc(len + 2);
iface->clientid[0] = len;
iface->clientid[1] = 0; /* string */
memcpy(iface->clientid + 2, options->clientid, len);
logger(LOG_INFO, "DUID = %s",
hwaddr_ntoa(duid, len));
- len += 5;
- iface->clientid = xmalloc(len);
- iface->clientid[0] = len;
+ iface->clientid = xmalloc(len + 6);
+ iface->clientid[0] = len + 5;
iface->clientid[1] = 255; /* RFC 4361 */
/* IAID is 4 bytes, so if the iface name is 4 bytes
#endif
if (len == 0) {
len = iface->hwlen + 1;
- iface->clientid = xmalloc(len);
+ iface->clientid = xmalloc(len + 1);
iface->clientid[0] = len;
iface->clientid[1] = iface->family;
- memcpy(iface->clientid + 1, iface->hwaddr, iface->hwlen);
+ memcpy(iface->clientid + 2, iface->hwaddr, iface->hwlen);
}
}
p += 2;
}
- if (iface->clientid[0]) {
+ if (iface->clientid) {
*p++ = DHCP_CLIENTID;
memcpy(p, iface->clientid, iface->clientid[0] + 1);
p += iface->clientid[0] + 1;