Hello,

The patch from Bill was suggesting something like this:

             if cls_ is not None:
                 option = cls_.parser(buf, offset)
             else:
-                option = buf[offset:offset + (length * 8 - 2)]
+                assert length > 0   # avoid infinite loop when length=0
+                option = buf[offset:offset + (length * 8)]
             options.append(option)
             offset += len(option)
         msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)


Would it be good to check for length too?

Thanks

/Shivaram

On Tue, Aug 1, 2017 at 7:18 PM, Satoshi Fujimoto <
satoshi.fujimo...@gmail.com> wrote:

> The length of nd_option is units of 8 octets.
> Currently, for nd_options which is undefined in the ICMPv6 packet library,
> the parser assumes that the length is [8 * length - 2].
> It causes fails while parsing these options.
>
> This patch fixes it to parse such options correctly.
>
> Signed-off-by: Satoshi Fujimoto <satoshi.fujimo...@gmail.com>
> ---
>  ryu/lib/packet/icmpv6.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
> index 1e5eaea..7608169 100644
> --- a/ryu/lib/packet/icmpv6.py
> +++ b/ryu/lib/packet/icmpv6.py
> @@ -363,7 +363,7 @@ class nd_router_advert(stringify.StringifyMixin):
>              if cls_ is not None:
>                  option = cls_.parser(buf, offset)
>              else:
> -                option = buf[offset:offset + (length * 8 - 2)]
> +                option = buf[offset:offset + (length * 8)]
>              options.append(option)
>              offset += len(option)
>          msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)
> --
> 2.7.4
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to