diff options
author | xkernel <xkernel.wang@foxmail.com> | 2022-02-21 15:17:46 +0800 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-02-28 19:26:49 +1100 |
commit | 37be6feeebfec87733e5cb4762fc12bebba9f124 (patch) | |
tree | 0ac020bc273e3257b1fb8c9f740368cf9b2b15f9 /apps | |
parent | 28e141c45d36757e052b72685fb874968f013d43 (diff) |
check the return value of CRYPTO_strdup()
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17741)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/req.c | 7 | ||||
-rw-r--r-- | apps/s_client.c | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/apps/req.c b/apps/req.c index 45de46d393..76b337f6bc 100644 --- a/apps/req.c +++ b/apps/req.c @@ -1588,6 +1588,13 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr, *pkeytype = OPENSSL_strndup(keytype, keytypelen); else *pkeytype = OPENSSL_strdup(keytype); + + if (*pkeytype == NULL) { + BIO_printf(bio_err, "Out of memory\n"); + EVP_PKEY_free(param); + return NULL; + } + if (keylen >= 0) *pkeylen = keylen; diff --git a/apps/s_client.c b/apps/s_client.c index cbce988c97..208595613b 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -811,7 +811,7 @@ int s_client_main(int argc, char **argv) char *cert_file = NULL, *key_file = NULL, *chain_file = NULL; char *chCApath = NULL, *chCAfile = NULL, *chCAstore = NULL, *host = NULL; char *thost = NULL, *tport = NULL; - char *port = OPENSSL_strdup(PORT); + char *port = NULL; char *bindhost = NULL, *bindport = NULL; char *passarg = NULL, *pass = NULL; char *vfyCApath = NULL, *vfyCAfile = NULL, *vfyCAstore = NULL; @@ -914,10 +914,11 @@ int s_client_main(int argc, char **argv) c_debug = 0; c_showcerts = 0; c_nbio = 0; + port = OPENSSL_strdup(PORT); vpm = X509_VERIFY_PARAM_new(); cctx = SSL_CONF_CTX_new(); - if (vpm == NULL || cctx == NULL) { + if (port == NULL || vpm == NULL || cctx == NULL) { BIO_printf(bio_err, "%s: out of memory\n", opt_getprog()); goto end; } |