Re: [PATCH ulogd2 2/6] db, IP2BIN: correct `format_ipv6()` output buffer sizes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeremy Sowden <jeremy@xxxxxxxxxx> wrote:
> On 2025-04-23, at 13:22:04 +0200, Florian Westphal wrote:
> > 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)?
> 
> A POSIX-compliant one? :)
> 
> 	The <netinet/in.h> header shall define the in6_addr structure, which shall include at least the following member:
> 
> 	  uint8_t s6_addr[16]
> 
> I dare say it's hair-splitting, but it's the size of the `s6_addr` member that
> is significant, not the structure as a whole.

I'd argue that sizeof(struct in6_addr) > 128 bits is a bug...

In any case i've never seen a definition of in6_addr where there is any
member that would cause this.

> > First patch looks good, I'll apply it later today.  Still reviewing the
> > rest.

FTR, I applied patches 1 and 3 to uglog2.git.




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux