]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2387] Add key data size check in InputBuffer constructor too
authorMukund Sivaraman <muks@isc.org>
Thu, 14 Mar 2013 02:11:58 +0000 (07:41 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 14 Mar 2013 02:11:58 +0000 (07:41 +0530)
src/lib/dns/rdata/generic/dnskey_48.cc

index f5b45c48b10145bf54092b1a25cae0a78ba6edfe..449a84f046cb9ddfca457372e632595dde35e90d 100644 (file)
@@ -101,6 +101,12 @@ DNSKEY::DNSKEY(InputBuffer& buffer, size_t rdata_len) {
     vector<uint8_t> keydata(rdata_len);
     buffer.readData(&keydata[0], rdata_len);
 
+    // See RFC 4034 appendix B.1 for why the key data has to be at least
+    // 3 bytes long with RSA/MD5.
+    if (algorithm == 1 && keydata.size() < 3) {
+        isc_throw(InvalidRdataLength, "DNSKEY keydata too short");
+    }
+
     impl_ = new DNSKEYImpl(flags, protocol, algorithm, keydata);
 }