Jeremy Sowden <jeremy@xxxxxxxxxx> wrote: > `format_ipv6()` formats IPv6 addresses as hex-strings. However, sizing for the > output buffer is not done quite right. > > `format_ipv6()` itself uses the size of `struct in6_addr` to verify that the > buffer size is large enough, and the output buffer for the call in util/db.c is > sized the same way. However, the size that should be used is that of the > `s6_addr` member of `struct in6_addr`, not that of the whole structure. ? In what uinverse is sizeof(struct in6_addr) different from sizeof(((struct in6_addr) {}).s6_addr)? > The elements of the `ipbin_array` array in ulogd_filter_IP2BIN.c are sized using > a local macro, `IPADDR_LENGTH`, which is defined as 128, the number of bits in > an IPv6 address; this is much larger than necessary. Agreed. > +#define FORMAT_IPV6_BUFSZ (2 + sizeof(((struct in6_addr) {}).s6_addr) * 2 + 1) I'd prefer to not use the .s6_addr, its not needed. > - for (unsigned j = 0; i < sizeof(*ipv6); j += 4, i += 8) { > + for (unsigned j = 0; i < sizeof(ipv6->s6_addr); j += 4, i += 8) { I would leave this as-is. First patch looks good, I'll apply it later today. Still reviewing the rest.