]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check that 'e' and 'n' are non-NULL in opensslrsa_todns
authorMark Andrews <marka@isc.org>
Mon, 26 Sep 2022 01:52:55 +0000 (11:52 +1000)
committerMark Andrews <marka@isc.org>
Tue, 27 Sep 2022 23:56:03 +0000 (09:56 +1000)
(cherry picked from commit 5603cd69d170f49916bec3ca78ab3e4830170950)

lib/dns/opensslrsa_link.c

index 7aa743394b511fc421c37cdc29e033d29da7bc8e..b23b6323fac1ccf62a0896815e43f57534af237d 100644 (file)
@@ -585,13 +585,15 @@ opensslrsa_todns(const dst_key_t *key, isc_buffer_t *data) {
        if (rsa == NULL) {
                return (dst__openssl_toresult(DST_R_OPENSSLFAILURE));
        }
-
-       isc_buffer_availableregion(data, &r);
-
        RSA_get0_key(rsa, &n, &e, NULL);
+       if (e == NULL || n == NULL) {
+               DST_RET(dst__openssl_toresult(DST_R_OPENSSLFAILURE));
+       }
        mod_bytes = BN_num_bytes(n);
        e_bytes = BN_num_bytes(e);
 
+       isc_buffer_availableregion(data, &r);
+
        if (e_bytes < 256) { /*%< key exponent is <= 2040 bits */
                if (r.length < 1) {
                        DST_RET(ISC_R_NOSPACE);