mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
[master] address buffer accounting error
4168. [security] A buffer accounting error could trigger an assertion failure when parsing certain malformed DNSSEC keys. (CVE-2015-5722) [RT #40212]
This commit is contained in:
@@ -971,6 +971,7 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
|
||||
RSA *rsa;
|
||||
isc_region_t r;
|
||||
unsigned int e_bytes;
|
||||
unsigned int length;
|
||||
#if USE_EVP
|
||||
EVP_PKEY *pkey;
|
||||
#endif
|
||||
@@ -978,6 +979,7 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
|
||||
isc_buffer_remainingregion(data, &r);
|
||||
if (r.length == 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
length = r.length;
|
||||
|
||||
rsa = RSA_new();
|
||||
if (rsa == NULL)
|
||||
@@ -988,17 +990,18 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
|
||||
RSA_free(rsa);
|
||||
return (DST_R_INVALIDPUBLICKEY);
|
||||
}
|
||||
e_bytes = *r.base++;
|
||||
r.length--;
|
||||
e_bytes = *r.base;
|
||||
isc_region_consume(&r, 1);
|
||||
|
||||
if (e_bytes == 0) {
|
||||
if (r.length < 2) {
|
||||
RSA_free(rsa);
|
||||
return (DST_R_INVALIDPUBLICKEY);
|
||||
}
|
||||
e_bytes = ((*r.base++) << 8);
|
||||
e_bytes += *r.base++;
|
||||
r.length -= 2;
|
||||
e_bytes = (*r.base) << 8;
|
||||
isc_region_consume(&r, 1);
|
||||
e_bytes += *r.base;
|
||||
isc_region_consume(&r, 1);
|
||||
}
|
||||
|
||||
if (r.length < e_bytes) {
|
||||
@@ -1006,14 +1009,13 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
|
||||
return (DST_R_INVALIDPUBLICKEY);
|
||||
}
|
||||
rsa->e = BN_bin2bn(r.base, e_bytes, NULL);
|
||||
r.base += e_bytes;
|
||||
r.length -= e_bytes;
|
||||
isc_region_consume(&r, e_bytes);
|
||||
|
||||
rsa->n = BN_bin2bn(r.base, r.length, NULL);
|
||||
|
||||
key->key_size = BN_num_bits(rsa->n);
|
||||
|
||||
isc_buffer_forward(data, r.length);
|
||||
isc_buffer_forward(data, length);
|
||||
|
||||
#if USE_EVP
|
||||
pkey = EVP_PKEY_new();
|
||||
|
Reference in New Issue
Block a user