ip6opt.c

Mark Martinec Mark.Martinec+freebsd at ijs.si
Tue Feb 4 00:05:24 UTC 2014


> Eitan Adler <lists at 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


More information about the freebsd-net mailing list