Fix the rare case of not added the new interface when sorting.
authorRoy Marples <roy@marples.name>
Thu, 11 Sep 2014 11:45:40 +0000 (11:45 +0000)
committerRoy Marples <roy@marples.name>
Thu, 11 Sep 2014 11:45:40 +0000 (11:45 +0000)
src/libdhcpcd/dhcpcd.c

index 919c8ffd0f8fd3c9cf79c7aa430e6f6c7df87dda..9efc95041b116ecede20edf45c09ec422c38ade4 100644 (file)
@@ -308,6 +308,7 @@ dhcpcd_new_if(DHCPCD_CONNECTION *con, char *data, size_t len)
        char *orderdup, *o, *p;
        DHCPCD_IF *e, *i, *l, *n, *nl;
        int ti;
+       bool addedi;
 
        ifname = get_value(data, len, "interface=");
        if (ifname == NULL || *ifname == '\0') {
@@ -432,6 +433,7 @@ dhcpcd_new_if(DHCPCD_CONNECTION *con, char *data, size_t len)
        /* Sort! */
        n = nl = NULL;
        p = orderdup;
+       addedi = false;
         while ((o = strsep(&p, " ")) != NULL) {
                 for (ti = 0; dhcpcd_types[ti]; ti++) {
                         l = NULL;
@@ -443,6 +445,8 @@ dhcpcd_new_if(DHCPCD_CONNECTION *con, char *data, size_t len)
                         }
                         if (e == NULL)
                                 continue;
+                       if (i == e)
+                               addedi = true;
                         if (l)
                                 l->next = e->next;
                         else
@@ -467,7 +471,7 @@ dhcpcd_new_if(DHCPCD_CONNECTION *con, char *data, size_t len)
         }
         con->interfaces = n;
 
-       return i;
+       return addedi ? i : NULL;
 }
 
 static DHCPCD_IF *