]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/dhcpv6.c
Fix building with clang 3.4
[odhcp6c.git] / src / dhcpv6.c
index 20343e47538a68d3280c36435bef0d59ff346c82..c87d289e159687b03aa3fc87f1c9b98b3651c06d 100644 (file)
@@ -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;