From: Bob Halley Date: Sat, 13 Jun 2015 12:26:21 +0000 (-0700) Subject: Fix CAA from_wire() X-Git-Tag: v1.13.0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=465785f85f87508209117264c677080e901e957c;p=thirdparty%2Fdnspython.git Fix CAA from_wire() --- diff --git a/dns/rdtypes/ANY/CAA.py b/dns/rdtypes/ANY/CAA.py index 3bd52a09..15e0f622 100644 --- a/dns/rdtypes/ANY/CAA.py +++ b/dns/rdtypes/ANY/CAA.py @@ -67,7 +67,7 @@ class CAA(dns.rdata.Rdata): (flags, l) = struct.unpack('!BB', wire[current : current + 2]) current += 2 tag = wire[current : current + l].unwrap() - value = wire[current + l:].unwrap() + value = wire[current + l:current + rdlen - 2].unwrap() return cls(rdclass, rdtype, flags, tag, value) from_wire = classmethod(from_wire) diff --git a/tests/test_bugs.py b/tests/test_bugs.py index cee87575..bb482e76 100644 --- a/tests/test_bugs.py +++ b/tests/test_bugs.py @@ -13,6 +13,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import cStringIO import unittest import dns.rdata @@ -52,5 +53,17 @@ class BugsTestCase(unittest.TestCase): "", 0, 0) self.failUnless(rdata == rdata2) + def test_CAA_from_wire(self): + rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CAA, + '0 issue "ca.example.net"'); + f = cStringIO.StringIO() + rdata.to_wire(f) + wire = f.getvalue() + rdlen = len(wire) + wire += "trailing garbage" + rdata2 = dns.rdata.from_wire(dns.rdataclass.IN, dns.rdatatype.CAA, + wire, 0, rdlen) + self.failUnless(rdata == rdata2) + if __name__ == '__main__': unittest.main()