Can't resolve 46 characters domains

Bug #1502853 reported by Petr Czepiec
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
py3dns
Fix Released
Medium
Unassigned

Bug Description

Hi,

It's not possible resolve domain if any part of DNS (label) have 46 characters, for example:

>>> DNS.dnslookup('1234567890123456789012345678901234567890123456', 'a')
Traceback (most recent call last):
  File "/usr/lib64/python3.4/encodings/idna.py", line 165, in encode
    raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/site-packages/DNS/lazy.py", line 37, in dnslookup
    result = Base.DnsRequest(name=name, qtype=qtype).req()
  File "/usr/lib/python3.4/site-packages/DNS/Base.py", line 319, in req
    m.addQuestion(qname, qtype, Class.IN)
  File "/usr/lib/python3.4/site-packages/DNS/Lib.py", line 628, in addQuestion
    self.addname(qname)
  File "/usr/lib/python3.4/site-packages/DNS/Lib.py", line 192, in addname
    buf = buf + (bytes(chr(n), enc) + label)
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

I think line 192 of Lib.py:
buf = buf + (bytes(chr(n), enc) + label)
is a nonsense (why is there IDNA encoding for num of chars of label?)

Thanks,
Petr Czepiec

Related branches

Revision history for this message
Petr Czepiec (petr-czepiec) wrote :

I fixed it in branch https://code.launchpad.net/~petr-czepiec/py3dns/py3dns, file DNS/Lib.py, line 192:
buf = buf + bytes([n]) + label

please check and merge it,

Petr Czepiec

Changed in py3dns:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Scott Kitterman (kitterman) wrote :

I'm not sure why I didn't see this when it came in. Sorry for the delay. Thanks for the fix. I'll release something with this included shortly.

Changed in py3dns:
status: Triaged → Fix Committed
Revision history for this message
Scott Kitterman (kitterman) wrote :

Fixed in 3.1.1.

Changed in py3dns:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.