Bug 1312770 - Undefined response_time in finally section of udp() (upstream has fix for this problem)
Summary: Undefined response_time in finally section of udp() (upstream has fix for thi...
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python-dns
Version: 7.2
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Charalampos Stratakis
QA Contact: Jan Houska
Marc Muehlfeld
Depends On:
Blocks: 1305230
TreeView+ depends on / blocked
Reported: 2016-02-29 09:21 UTC by Anatoly
Modified: 2016-11-04 04:30 UTC (History)
8 users (show)

Fixed In Version: python-dns-1.12.0-2.20150617git465785f.el7
Doc Type: Bug Fix
Doc Text:
Undefined variable in the `udp()` function of the _python-dns_ toolkit is now set Previously, the _python-dns_ toolkit used an undefined `response_time` variable in the *finally* section of the `udp()` function. As a consequence, an incorrect exception was displayed to the user. This bug has been fixed and the correct exception is returned.
Clone Of:
Last Closed: 2016-11-04 04:30:58 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2354 0 normal SHIPPED_LIVE python-dns bug fix update 2016-11-03 13:48:28 UTC

Description Anatoly 2016-02-29 09:21:43 UTC
Description of problem:

python-dns 1.12.0 has undefined response_time variable in finally section of udp() function. This bug lead to incorrect exception in this function. For example this lead to UnboundLocalError instead of Timeout exception.
Upstream has fix for this problem https://github.com/rthalley/dnspython/commit/daf723176da7bfee5baae928ff1af310a2400289
This problem new for RHEL 7.2 and doesn't presents in previous versions.

Version-Release number of selected component (if applicable): 1.12.0

Comment 3 Charalampos Stratakis 2016-04-04 11:11:21 UTC
Could you provide a reproducer?

Comment 4 Anatoly 2016-04-05 09:05:52 UTC

from dns.resolver import Resolver

r = Resolver()
r.nameservers = [ '', ]
r.timeout = 2
r.lifetime = 2
answers = r.query( 'redhat.com', 'SOA', source_port = 53 )

This script should be started on host with port 53/udp assigned e.g. on host with named started.

Results on host with patch:

Traceback (most recent call last):
  File "./query-bug.py", line 9, in <module>
    answers = r.query( 'redhat.com', 'SOA', source_port = 53 )
  File "/usr/lib/python2.7/site-packages/dns/resolver.py", line 857, in query
    timeout = self._compute_timeout(start)
  File "/usr/lib/python2.7/site-packages/dns/resolver.py", line 769, in _compute_timeout
    raise Timeout(timeout=duration)
dns.exception.Timeout: The DNS operation timed out after 2.00053596497 seconds

Results with not patched version of python-dns:

Traceback (most recent call last):
  File "./query-bug.py", line 9, in <module>
    answers = r.query( 'redhat.com', 'SOA', source_port = 53 )
  File "/usr/lib/python2.7/site-packages/dns/resolver.py", line 869, in query
  File "/usr/lib/python2.7/site-packages/dns/query.py", line 227, in udp
    response_time = time.time() - begin_time
UnboundLocalError: local variable 'begin_time' referenced before assignment

Correct result for this case is dns.exception.Timeout incorrect results is UnboundLocalError

Comment 13 errata-xmlrpc 2016-11-04 04:30:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.