]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use ifnames of less than 4 bytes in the IAID as well.
authorRoy Marples <roy@marples.name>
Fri, 4 Jul 2008 13:20:20 +0000 (13:20 +0000)
committerRoy Marples <roy@marples.name>
Fri, 4 Jul 2008 13:20:20 +0000 (13:20 +0000)
client.c

index 977ed19407f4a857a18320fc1e7726f8a03e75db..c24e8caf32510c6f06694d272990a31fb73bd325 100644 (file)
--- 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));