}
if ((packet[0] == DHCPV6_RELAY_FORW) ||
(packet[0] == DHCPV6_RELAY_REPL)) {
- if (len >= sizeof(struct dhcpv6_relay_packet)) {
+ if (len >= offsetof(struct dhcpv6_relay_packet, options)) {
return 1;
} else {
return 0;
}
} else {
- if (len >= sizeof(struct dhcpv6_packet)) {
+ if (len >= offsetof(struct dhcpv6_packet, options)) {
return 1;
} else {
return 0;
# Try to add the bind include directory
CFLAGS="$CFLAGS -I$libbind/include"
+AC_C_FLEXIBLE_ARRAY_MEMBER
+
AC_OUTPUT([
Makefile
client/Makefile
struct dhcpv6_packet {
unsigned char msg_type;
unsigned char transaction_id[3];
- unsigned char options[0];
+ unsigned char options[FLEXIBLE_ARRAY_MEMBER];
};
/* Offset into DHCPV6 Reply packets where Options spaces commence. */
unsigned char hop_count;
unsigned char link_address[16];
unsigned char peer_address[16];
- unsigned char options[0];
+ unsigned char options[FLEXIBLE_ARRAY_MEMBER];
};
/* Leasequery query-types (RFC 5007) */
if (len == 0)
return 0;
- /* The switch indexes our starting position into the do/while loop,
- * taking up the remainder after hashing in all the other bytes in
- * threes.
+ /*
+ * The switch handles our starting conditions, then we hash the
+ * remaining bytes in groups of 3
*/
+
switch (len % 3) {
- do {
- case 0:
- accum ^= *s++ << 16;
- case 2:
- accum ^= *s++ << 8;
- case 1:
- accum ^= *s++;
- } while (s < end);
-
+ case 0:
+ break;
+ case 2:
+ accum ^= *s++ << 8;
+ case 1:
+ accum ^= *s++;
break;
}
+ while (s < end) {
+ accum ^= *s++ << 16;
+ accum ^= *s++ << 8;
+ accum ^= *s++;
+ }
+
return accum % size;
}
/* Build the relay-forward header. */
relay = (struct dhcpv6_relay_packet *) forw_data;
- cursor = sizeof(*relay);
+ cursor = offsetof(struct dhcpv6_relay_packet, options);
relay->msg_type = DHCPV6_RELAY_FORW;
if (packet->dhcpv6_msg_type == DHCPV6_RELAY_FORW) {
if (packet->dhcpv6_hop_count >= max_hop_count) {
if (!evaluate_option_cache(&relay_msg, packet, NULL, NULL,
packet->options, NULL,
&global_scope, oc, MDL) ||
- (relay_msg.len < sizeof(struct dhcpv6_packet))) {
+ (relay_msg.len < offsetof (struct dhcpv6_packet, options))) {
log_error("Can't evaluate relay-msg.");
return;
}
piaddr (hw_lease -> ip_addr));
#endif
goto n_hw;
- continue;
}
if (hw_lease -> subnet -> shared_network != share) {
#if defined (DEBUG_FIND_LEASE)
piaddr (hw_lease -> ip_addr));
#endif
goto n_hw;
- continue;
}
if ((hw_lease -> pool -> prohibit_list &&
permitted (packet, hw_lease -> pool -> prohibit_list)) ||
isc_boolean_t inappropriate, has_addrs;
char reply_data[65536];
struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data;
- int reply_ofs = (int)((char *)reply->options - (char *)reply);
+ int reply_ofs = (int)(offsetof(struct dhcpv6_packet, options));
/*
* Basic client message validation.
int iaaddr_is_found;
char reply_data[65536];
struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data;
- int reply_ofs = (int)((char *)reply->options - (char *)reply);
+ int reply_ofs = (int)(offsetof(struct dhcpv6_packet, options));
char status_msg[32];
struct iasubopt *lease;
struct ia_xx *existing_ia_na;
sizeof(reply->link_address));
memcpy(reply->peer_address, &packet->dhcpv6_peer_address,
sizeof(reply->peer_address));
- reply_ofs = (int)((char *)reply->options - (char *)reply);
+ reply_ofs = (int)(offsetof(struct dhcpv6_relay_packet, options));
/*
* Get the reply option state.
#include <isc/md5.h>
HASH_FUNCTIONS(ia, unsigned char *, struct ia_xx, ia_hash_t,
- ia_reference, ia_dereference, do_string_hash);
+ ia_reference, ia_dereference, do_string_hash)
ia_hash_t *ia_na_active;
ia_hash_t *ia_ta_active;
ia_hash_t *ia_pd_active;
HASH_FUNCTIONS(iasubopt, struct in6_addr *, struct iasubopt, iasubopt_hash_t,
- iasubopt_reference, iasubopt_dereference, do_string_hash);
+ iasubopt_reference, iasubopt_dereference, do_string_hash)
struct ipv6_pool **pools;
int num_pools;
} else
return DHCP_R_INVALIDARG;
- return ISC_R_SUCCESS;
+ /*
+ * Currently no way to get here, if we update the above
+ * code so that we do get here this return needs to be
+ * uncommented.
+ * return ISC_R_SUCCESS;
+ */
}