2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

memory leaks on errors

This commit is contained in:
Brian Wellington
2001-11-06 17:59:50 +00:00
parent 62c1fe7b45
commit 3bc4de1f1b

View File

@@ -17,7 +17,7 @@
/* /*
* Principal Author: Brian Wellington * Principal Author: Brian Wellington
* $Id: opensslrsa_link.c,v 1.13 2001/09/15 00:01:56 bwelling Exp $ * $Id: opensslrsa_link.c,v 1.14 2001/11/06 17:59:50 bwelling Exp $
*/ */
#ifdef OPENSSL #ifdef OPENSSL
@@ -311,21 +311,27 @@ opensslrsa_fromdns(dst_key_t *key, isc_buffer_t *data) {
return (ISC_R_NOMEMORY); return (ISC_R_NOMEMORY);
rsa->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE); rsa->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE);
if (r.length < 1) if (r.length < 1) {
RSA_free(rsa);
return (DST_R_INVALIDPUBLICKEY); return (DST_R_INVALIDPUBLICKEY);
}
e_bytes = *r.base++; e_bytes = *r.base++;
r.length--; r.length--;
if (e_bytes == 0) { if (e_bytes == 0) {
if (r.length < 2) if (r.length < 2) {
RSA_free(rsa);
return (DST_R_INVALIDPUBLICKEY); return (DST_R_INVALIDPUBLICKEY);
}
e_bytes = ((*r.base++) << 8); e_bytes = ((*r.base++) << 8);
e_bytes += *r.base++; e_bytes += *r.base++;
r.length -= 2; r.length -= 2;
} }
if (r.length < e_bytes) if (r.length < e_bytes) {
RSA_free(rsa);
return (DST_R_INVALIDPUBLICKEY); return (DST_R_INVALIDPUBLICKEY);
}
rsa->e = BN_bin2bn(r.base, e_bytes, NULL); rsa->e = BN_bin2bn(r.base, e_bytes, NULL);
r.base += e_bytes; r.base += e_bytes;
r.length -= e_bytes; r.length -= e_bytes;