From: Roy Marples Date: Fri, 4 Jul 2008 13:20:20 +0000 (+0000) Subject: Use ifnames of less than 4 bytes in the IAID as well. X-Git-Tag: v4.0.2~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09da00df6426394a56cd188d901241a7781ff458;p=thirdparty%2Fdhcpcd.git Use ifnames of less than 4 bytes in the IAID as well. --- diff --git a/client.c b/client.c index 977ed194..c24e8caf 100644 --- a/client.c +++ b/client.c @@ -544,9 +544,13 @@ client_setup(struct if_state *state, const struct options *options) iface->clientid[1] = 255; /* RFC 4361 */ /* IAID is 4 bytes, so if the iface name is 4 bytes - * use it */ - if (strlen(iface->name) == 4) { - memcpy(iface->clientid + 2, iface->name, 4); + * or less, use it */ + ul = strlen(iface->name); + if (ul < 5) { + memcpy(iface->clientid + 2, iface->name, ul); + if (ul < 4) + memset(iface->clientid + 2 + ul, + 0, 4 - ul); } else { /* Name isn't 4 bytes, so use the index */ ul = htonl(if_nametoindex(iface->name));