aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rsa
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2004-12-05 01:03:15 +0000
committerDr. Stephen Henson <steve@openssl.org>2004-12-05 01:03:15 +0000
commita0e7c8eede26b29b09057f48b8e51f46f8811ddd (patch)
tree2b50575b4e9e608b61cb74246915625bd99b85d8 /crypto/rsa
parenta8e00b17ce840c58787e45411fa2ac4d6b1fb10c (diff)
downloadopenssl-a0e7c8eede26b29b09057f48b8e51f46f8811ddd.tar.gz
Add lots of checks for memory allocation failure, error codes to indicate
failure and freeing up memory if a failure occurs. PR:620
Diffstat (limited to 'crypto/rsa')
-rw-r--r--crypto/rsa/rsa_saos.c7
-rw-r--r--crypto/rsa/rsa_sign.c9
2 files changed, 11 insertions, 5 deletions
diff --git a/crypto/rsa/rsa_saos.c b/crypto/rsa/rsa_saos.c
index 1e9339367f..f98e0a80a6 100644
--- a/crypto/rsa/rsa_saos.c
+++ b/crypto/rsa/rsa_saos.c
@@ -140,8 +140,11 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype,
ret=1;
err:
if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
- OPENSSL_cleanse(s,(unsigned int)siglen);
- OPENSSL_free(s);
+ if (s != NULL)
+ {
+ OPENSSL_cleanse(s,(unsigned int)siglen);
+ OPENSSL_free(s);
+ }
return(ret);
}
diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c
index e50c839279..9e7dfd1927 100644
--- a/crypto/rsa/rsa_sign.c
+++ b/crypto/rsa/rsa_sign.c
@@ -169,7 +169,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
}
if((dtype == NID_md5_sha1) && (m_len != SSL_SIG_LENGTH) ) {
RSAerr(RSA_F_RSA_VERIFY,RSA_R_INVALID_MESSAGE_LENGTH);
- return(0);
+ goto err;
}
i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);
@@ -222,8 +222,11 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
}
err:
if (sig != NULL) X509_SIG_free(sig);
- OPENSSL_cleanse(s,(unsigned int)siglen);
- OPENSSL_free(s);
+ if (s != NULL)
+ {
+ OPENSSL_cleanse(s,(unsigned int)siglen);
+ OPENSSL_free(s);
+ }
return(ret);
}