X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=src%2Fdhcpv6.c;h=c87d289e159687b03aa3fc87f1c9b98b3651c06d;hb=6c8109e0c77d5a54950ba607d1ec1f83d5efb5b7;hp=20343e47538a68d3280c36435bef0d59ff346c82;hpb=7dcb066e88b3b201e29b308d896030573659acf4;p=odhcp6c.git diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 20343e4..c87d289 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -248,7 +248,7 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) void *srv_id = odhcp6c_get_state(STATE_SERVER_ID, &srv_id_len); // Build IA_PDs - size_t ia_pd_entries, ia_pd_len = 0; + size_t ia_pd_entries = 0, ia_pd_len = 0; uint8_t *ia_pd; if (type == DHCPV6_MSG_SOLICIT) { @@ -445,16 +445,14 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) } // Disable IAs if not used - if (type != DHCPV6_MSG_SOLICIT) { - iov[IOV_RECONF_ACCEPT].iov_len = 0; - if (ia_na_len == 0) - iov[IOV_HDR_IA_NA].iov_len = 0; - } + if (type != DHCPV6_MSG_SOLICIT && ia_na_len == 0) + iov[IOV_HDR_IA_NA].iov_len = 0; if (na_mode == IA_MODE_NONE) iov[IOV_HDR_IA_NA].iov_len = 0; - if (!(client_options & DHCPV6_ACCEPT_RECONFIGURE)) + if ((type != DHCPV6_MSG_SOLICIT && type != DHCPV6_MSG_REQUEST) || + !(client_options & DHCPV6_ACCEPT_RECONFIGURE)) iov[IOV_RECONF_ACCEPT].iov_len = 0; if (!(client_options & DHCPV6_CLIENT_FQDN)) @@ -659,10 +657,12 @@ static bool dhcpv6_response_is_valid(const void *buf, ssize_t len, continue; md5_ctx_t md5; - uint8_t serverhash[16], secretbytes[16], hash[16]; + uint8_t serverhash[16], secretbytes[64], hash[16]; memcpy(serverhash, r->key, sizeof(serverhash)); memset(r->key, 0, sizeof(r->key)); - memcpy(secretbytes, reconf_key, sizeof(secretbytes)); + + memset(secretbytes, 0, sizeof(secretbytes)); + memcpy(secretbytes, reconf_key, sizeof(reconf_key)); for (size_t i = 0; i < sizeof(secretbytes); ++i) secretbytes[i] ^= 0x36;