Closed Emzi0767 closed 1 year ago
I have also now tested the changes under Python 3.10 on Ubuntu 22.04 LTS.
Can you check whether this bug still exists in the current development branch (halosaur)? I think it's probably fixed.
Quick glace shows the path to have been updated similar to my changes (sans retaining py2 compat). One thing I suspect is https://github.com/noxrepo/pox/blob/20d291825de5e1038e4500382e842e4f95b5731a/pox/lib/packet/dns.py#L401 due to retlist
being a str
list in the past. It appears to be a bytes
list now. I will properly test this in a couple hours.
I ran a more proper test, and it appears the issue is indeed resolved in halosaur.
Awesome; thanks for checking!
This commit introduces a compatibility fix in the dns packet decoder. This prevents the output from being spammed by failures to decode DNS requests (and presumably responses). The fix is tested under Python 3.9.2 on Debian 11, but steps were taken to retain Python 2 compatibility as well.
The original problems stems from how Python 2 and 3 handle
bytes
objects differently - Python 2 seems to just handle them asstr
objects, whereas under python 3 they arebytes
. This obviously leads to issues where conversion happen - in this casebytes
toint
andstr
. Whereas under Python 2,ord($OBJ)
is required to convert a byte to int, under Python 3 it is sufficient to just use the byte asint
. Similarly, sliced bytestring under Python 2 is already astr
object, whereas in Python 3 it requires.decode()
ing first (in Python 2 you can decode astr
object, but it yields aunicode
object, which might not be desirable).