Bug 1312770

Summary: Undefined response_time in finally section of udp() (upstream has fix for this problem)
Product: Red Hat Enterprise Linux 7 Reporter: Anatoly <tolyator>
Component: python-dnsAssignee: Charalampos Stratakis <cstratak>
Status: CLOSED ERRATA QA Contact: Jan Houska <jhouska>
Severity: unspecified Docs Contact: Marc Muehlfeld <mmuehlfe>
Priority: unspecified    
Version: 7.2CC: cstratak, isenfeld, jhouska, lmiksik, mmuehlfe, pviktori, qe-baseos-apps, tolyator
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 04:30:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1305230    

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
#!/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

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.

https://rhn.redhat.com/errata/RHBA-2016-2354.html