diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2016-12-23 14:35:16 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2017-01-09 22:36:43 +0100 |
commit | 2045c58116c11c990eee009e29cf72fc92c47daa (patch) | |
tree | 3df81cf8ab81692b85937b1cf94e26a530fa2f86 /crypto/rsa | |
parent | 18b8431f3b8a593bdcceb0d8f1c9612bddb77541 (diff) |
Fix a memory leak in RSA_padding_add_PKCS1_OAEP_mgf1
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #2140
(cherry picked from commit c6d215e0d278fcd51ad474a3647b61e1b67290bb)
Diffstat (limited to 'crypto/rsa')
-rw-r--r-- | crypto/rsa/rsa_oaep.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c index 9c2a943cf7..19d28c6f0e 100644 --- a/crypto/rsa/rsa_oaep.c +++ b/crypto/rsa/rsa_oaep.c @@ -89,17 +89,21 @@ int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, } if (PKCS1_MGF1(dbmask, emlen - mdlen, seed, mdlen, mgf1md) < 0) - return 0; + goto err; for (i = 0; i < emlen - mdlen; i++) db[i] ^= dbmask[i]; if (PKCS1_MGF1(seedmask, mdlen, db, emlen - mdlen, mgf1md) < 0) - return 0; + goto err; for (i = 0; i < mdlen; i++) seed[i] ^= seedmask[i]; OPENSSL_free(dbmask); return 1; + + err: + OPENSSL_free(dbmask); + return 0; } int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, |