Red Hat Bugzilla – Bug 1312770
Undefined response_time in finally section of udp() (upstream has fix for this problem)
Last modified: 2016-11-04 00:30:58 EDT
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
Could you provide a reproducer?
#!/usr/bin/python from dns.resolver import Resolver r = Resolver() r.nameservers = [ '127.0.0.1', ] 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 source_port=source_port) 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
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. https://rhn.redhat.com/errata/RHBA-2016-2354.html