diff options
author | Richard Levitte <levitte@openssl.org> | 2020-08-28 13:07:35 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-03 17:48:32 +0200 |
commit | 67b640135696d4426475fb0c455c094a6c33ee45 (patch) | |
tree | 3840e2fdd05ba03f2a18dfcdd913a89255810100 | |
parent | 7a3068109568cefdb0d63be1d0c83251c621156e (diff) | |
download | openssl-67b640135696d4426475fb0c455c094a6c33ee45.zip openssl-67b640135696d4426475fb0c455c094a6c33ee45.tar.gz openssl-67b640135696d4426475fb0c455c094a6c33ee45.tar.bz2 |
CORE: Fix small bug in passphrase caching
Passphrase caching didn't allocate memory when it got to cache an
empty string, leading to a crash.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12587)
-rw-r--r-- | crypto/passphrase.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/passphrase.c b/crypto/passphrase.c index ac35269..170374f 100644 --- a/crypto/passphrase.c +++ b/crypto/passphrase.c @@ -273,7 +273,8 @@ int ossl_pw_get_passphrase(char *pass, size_t pass_size, size_t *pass_len, do_cache: if (ret && data->flag_cache_passphrase) { - if (*pass_len > data->cached_passphrase_len) { + if (data->cached_passphrase == NULL + || *pass_len > data->cached_passphrase_len) { void *new_cache = OPENSSL_clear_realloc(data->cached_passphrase, data->cached_passphrase_len, |