djhenderson / dpkt

Automatically exported from code.google.com/p/dpkt
Other
1 stars 0 forks source link

ip6.IP6._protosw.update() is premature #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using Python 2.7 which randomizes hash key order, ip.__load_protos() may 
implicitly __import__() the ip6 module before some of the other protocols are 
populated into ip.IP._protosw.  If we do IP6._protosw.update(ip.IP._protosw) as 
is done currently, then IP6 would only get a subset of protocols that happen to 
be defined so far, and due to hash key randomization, this could very well be 
the empty set.

Moreover, ip6 could not import ip before class IP6 is defined.  The workaround 
here is to do this after class IP6, forcing the sharing of dictionary rather 
than making a copy.

import ip
IP6._protosw = ip.IP._protosw

Attaching a patch which I verified to work.

liulk

Original issue reported on code.google.com by liulk@google.com on 28 Nov 2012 at 5:43

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by andrewf...@gmail.com on 15 Dec 2012 at 7:52