From: Martin Schwenke Date: Tue, 14 Aug 2018 01:25:02 +0000 (+1000) Subject: ctdb-common: Be more careful with packet sizes X-Git-Tag: tdb-1.3.17~1974 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2a00feca3565d3071424246bb25ad1623bdfe6c;p=thirdparty%2Fsamba.git ctdb-common: Be more careful with packet sizes Ethernet packets must be at least 64 bytes. For ARP the packet size was limited to 64 bytes. This is probably OK but the code might as well be a little more general. For IPv6 NA there was no guarantee that the packet is at least 64 bytes. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/common/system_socket.c b/ctdb/common/system_socket.c index ab7f6be5d71..c60243e9801 100644 --- a/ctdb/common/system_socket.c +++ b/ctdb/common/system_socket.c @@ -175,14 +175,19 @@ static uint16_t ip6_checksum(uint16_t *data, size_t n, struct ip6_hdr *ip6) * packets */ -#define ARP_BUFFER_SIZE 64 +#define ARP_STRUCT_SIZE sizeof(struct ether_header) + \ + sizeof(struct ether_arp) -#define IP6_NA_BUFFER_SIZE sizeof(struct ether_header) + \ +#define IP6_NA_STRUCT_SIZE sizeof(struct ether_header) + \ sizeof(struct ip6_hdr) + \ sizeof(struct nd_neighbor_advert) + \ sizeof(struct nd_opt_hdr) + \ sizeof(struct ether_addr) +#define ARP_BUFFER_SIZE MAX(ARP_STRUCT_SIZE, 64) + +#define IP6_NA_BUFFER_SIZE MAX(IP6_NA_STRUCT_SIZE, 64) + static int arp_build(uint8_t *buffer, size_t buflen, const struct sockaddr_in *addr,