Date: Tue, 04 Feb 2014 01:05:19 +0100 From: Mark Martinec <Mark.Martinec+freebsd@ijs.si> To: freebsd-net@freebsd.org Subject: Re: ip6opt.c Message-ID: <758be52b7a245c492ec80a1d3a21d79e@mailbox.ijs.si> In-Reply-To: <20140204.052625.1192023326694116318.hrs@allbsd.org> References: <CAF6rxgmQMXKDMETRPRE-QkQwGS3vgZxQRFKoe6d3_BycQOouYw@mail.gmail.com> <20140204.052625.1192023326694116318.hrs@allbsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> Eitan Adler <lists@eitanadler.com> wrote > li> DragonFly recently committed the following change and it seems that > it > li> applies to us as well. --- ip6opt.c (revision 261405) +++ ip6opt.c (working copy) @@ -381,11 +381,8 @@ inet6_opt_init(void *extbuf, socklen_t extlen) { struct ip6_ext *ext = (struct ip6_ext *)extbuf; - if (extlen < 0 || (extlen % 8)) - return(-1); - if (ext) { - if (extlen == 0) + if (extlen == 0 || (extlen % 8)) return(-1); ext->ip6e_len = (extlen >> 3) - 1; } 2014-02-03 21:26, Hiroki Sato wrote: > Just out of curiousity, what is the problem with returning -1 when > (extbuf == NULL) && (extlen % 8) != 0? It is against the specs. The RFC 3542 is clear on this: 10.1. inet6_opt_init int inet6_opt_init(void *extbuf, socklen_t extlen); This function returns the number of bytes needed for the empty extension header i.e., without any options. If extbuf is not NULL it also initializes the extension header to have the correct length field. In that case if the extlen value is not a positive (i.e., non-zero) multiple of 8 the function fails and returns -1. li> Should I commit it? I'd say yes. Mark
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?758be52b7a245c492ec80a1d3a21d79e>