]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/dhcpv6.c
Check for unsupported PD exclusion configuration in dhcpv6_parse_ia
[odhcp6c.git] / src / dhcpv6.c
index a3e0a18e50ec1644b07110e371ac52bd6283ce27..2d8124f288171f966e777720254c401d7d3b14ce 100644 (file)
@@ -797,18 +797,6 @@ static int dhcpv6_handle_advert(enum dhcpv6_msg orig, const int rc,
                if (otype == DHCPV6_OPT_SERVERID && olen <= 130) {
                        memcpy(cand.duid, odata, olen);
                        cand.duid_len = olen;
-               } else if (otype == DHCPV6_OPT_STATUS && olen >= 2) {
-                       int error = ((int)odata[0] << 8 | (int)odata[1]);
-
-                       switch (error) {
-                       case DHCPV6_NoPrefixAvail:
-                               // Status code on global level
-                               cand.preference -= 2000;
-                               break;
-
-                       default :
-                               break;
-                       }
                } else if (otype == DHCPV6_OPT_PREF && olen >= 1 &&
                                cand.preference >= 0) {
                        cand.preference = pref = odata[0];
@@ -1197,7 +1185,7 @@ static int dhcpv6_parse_ia(void *opt, void *end)
                                if (elen > 64)
                                        elen = 64;
 
-                               if (elen <= 32 || elen <= entry.length) {
+                               if (entry.length < 32 || elen <= entry.length) {
                                        ok = false;
                                        continue;
                                }
@@ -1374,6 +1362,7 @@ static void dhcpv6_handle_ia_status_code(const enum dhcpv6_msg orig,
        }
 }
 
+// Note this always takes ownership of cand->ia_na and cand->ia_pd
 static void dhcpv6_add_server_cand(const struct dhcpv6_server_cand *cand)
 {
        size_t cand_len, i;
@@ -1396,7 +1385,10 @@ static void dhcpv6_add_server_cand(const struct dhcpv6_server_cand *cand)
                        break;
        }
 
-       odhcp6c_insert_state(STATE_SERVER_CAND, i * sizeof(*c), cand, sizeof(*cand));
+       if (odhcp6c_insert_state(STATE_SERVER_CAND, i * sizeof(*c), cand, sizeof(*cand))) {
+               free(cand->ia_na);
+               free(cand->ia_pd);
+       }
 }
 
 static void dhcpv6_clear_all_server_cand(void)