]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_9] fix md5 key id computation
authorEvan Hunt <each@isc.org>
Tue, 13 Aug 2013 23:04:48 +0000 (16:04 -0700)
committerEvan Hunt <each@isc.org>
Tue, 13 Aug 2013 23:04:48 +0000 (16:04 -0700)
3630. [bug] Ensure correct ID computation for MD5 keys. [RT #33033]
(cherry picked from commit 5d4343a9988cd5bd057aa385bb8c5e72d41202d1)

CHANGES
lib/dns/rdata/generic/dnskey_48.c
lib/dns/rdata/generic/key_25.c
lib/dns/rdata/generic/keydata_65533.c

diff --git a/CHANGES b/CHANGES
index 005c68cb00dcab88549ad3b2345bb405b6f99f92..cc446dade67a98815fcf83a8cd1785747e2b9caf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+3630.  [bug]           Ensure correct ID computation for MD5 keys. [RT #33033]
+
 3627.  [bug]           RPZ changes were not effective on slaves. [RT #34450]
 
 3625.  [bug]           Don't send notify messages to machines outside of the
index 688e7ac5e18f3329cd9a41f2c641eb8dd65d5d1a..9980b086763fc6967afe773185bb5fefcd23472a 100644 (file)
@@ -185,6 +185,15 @@ fromwire_dnskey(ARGS_FROMWIRE) {
                dns_name_init(&name, NULL);
                RETERR(dns_name_fromwire(&name, source, dctx, options, target));
        }
+
+       /*
+        * RSAMD5 computes key ID differently from other
+        * algorithms: we need to ensure there's enough data
+        * present for the computation
+        */
+       if (algorithm == DST_ALG_RSAMD5 && sr.length < 3)
+               return (ISC_R_UNEXPECTEDEND);
+
        isc_buffer_activeregion(source, &sr);
        isc_buffer_forward(source, sr.length);
        return (mem_tobuffer(target, sr.base, sr.length));
index 1d0ba83a9b3141e0f0c4f46b37873ed5ababfd2b..b5bc2075112acf98e85a24b5185671a505b55abf 100644 (file)
@@ -176,6 +176,15 @@ fromwire_key(ARGS_FROMWIRE) {
                dns_name_init(&name, NULL);
                RETERR(dns_name_fromwire(&name, source, dctx, options, target));
        }
+
+       /*
+        * RSAMD5 computes key ID differently from other
+        * algorithms: we need to ensure there's enough data
+        * present for the computation
+        */
+       if (algorithm == DST_ALG_RSAMD5 && sr.length < 3)
+               return (ISC_R_UNEXPECTEDEND);
+
        isc_buffer_activeregion(source, &sr);
        isc_buffer_forward(source, sr.length);
        return (mem_tobuffer(target, sr.base, sr.length));
index f1fe45e4b9f67ae2c824ef942cb6dceddc9aad83..a3ed8603fefc9645e5a6b05330e20c9c86b4f169 100644 (file)
@@ -185,6 +185,7 @@ totext_keydata(ARGS_TOTEXT) {
 static inline isc_result_t
 fromwire_keydata(ARGS_FROMWIRE) {
        isc_region_t sr;
+       unsigned char algorithm;
 
        REQUIRE(type == 65533);
 
@@ -197,6 +198,15 @@ fromwire_keydata(ARGS_FROMWIRE) {
        if (sr.length < 16)
                return (ISC_R_UNEXPECTEDEND);
 
+       /*
+        * RSAMD5 computes key ID differently from other
+        * algorithms: we need to ensure there's enough data
+        * present for the computation
+        */
+       algorithm = sr.base[15];
+       if (algorithm == DST_ALG_RSAMD5 && sr.length < 19)
+               return (ISC_R_UNEXPECTEDEND);
+
        isc_buffer_forward(source, sr.length);
        return (mem_tobuffer(target, sr.base, sr.length));
 }