Hi, Shivaram
Oops, I overlooked about it.
It is needed for not only avoiding infinite loop, but also complying RFC.
For the 'length' field in options, RFC4861 says that:
The value 0 is invalid. Nodes MUST
silently discard an ND packet that contains an
option with length zero.
So we should raise an exception when receiving such invalid packets.
I will make a patch.
Thanks,
Fujimoto
On 2017年08月02日 12:13, Shivaram Mysore wrote:
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 <mailto: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
<mailto: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
<mailto:Ryu-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<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