]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Fix CAA from_wire()
authorBob Halley <halley@dnspython.org>
Sat, 13 Jun 2015 12:26:21 +0000 (05:26 -0700)
committerBob Halley <halley@dnspython.org>
Sat, 13 Jun 2015 12:26:21 +0000 (05:26 -0700)
dns/rdtypes/ANY/CAA.py
tests/test_bugs.py

index 3bd52a09c43674161db726aa0e4e2b6e94e10a28..15e0f622a10f4133c7c180a52a6645711c536762 100644 (file)
@@ -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)
index cee875750f2a2c5d3ff309e81669e0d7c454f529..bb482e760cd627cde931e71c5a6c85f03bdbc171 100644 (file)
@@ -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()