diff options
| author | Bob Halley <halley@play-bow.org> | 2015-06-13 05:26:31 -0700 |
|---|---|---|
| committer | Bob Halley <halley@play-bow.org> | 2015-06-13 05:26:31 -0700 |
| commit | 1b0c15086f0e5f6eacc06d77a119280c31731b3c (patch) | |
| tree | 561eb29dc8bfbac491e9a94938bbaff454a2a279 | |
| parent | 2eaf67ae39bb7c8b1363b16736d7054a8c0fd967 (diff) | |
| download | dnspython-1b0c15086f0e5f6eacc06d77a119280c31731b3c.tar.gz | |
Fix CAA from_wire()
| -rw-r--r-- | dns/rdtypes/ANY/CAA.py | 2 | ||||
| -rw-r--r-- | tests/test_bugs.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/dns/rdtypes/ANY/CAA.py b/dns/rdtypes/ANY/CAA.py index 7425606..2381ea6 100644 --- a/dns/rdtypes/ANY/CAA.py +++ b/dns/rdtypes/ANY/CAA.py @@ -69,5 +69,5 @@ class CAA(dns.rdata.Rdata): (flags, l) = struct.unpack('!BB', wire[current : current + 2]) current += 2 tag = wire[current : current + l].decode('latin_1') - value = wire[current + l:].decode('latin_1') + value = wire[current + l:current + rdlen - 2].decode('latin_1') return cls(rdclass, rdtype, flags, tag, value) diff --git a/tests/test_bugs.py b/tests/test_bugs.py index 906e0fd..5aae6a4 100644 --- a/tests/test_bugs.py +++ b/tests/test_bugs.py @@ -14,6 +14,7 @@ # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import binascii +import io import unittest import dns.rdata @@ -59,6 +60,17 @@ class BugsTestCase(unittest.TestCase): b"", 0, 0) self.assertTrue(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 = io.BytesIO() + rdata.to_wire(f) + wire = f.getvalue() + rdlen = len(wire) + wire += b"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() |
