summaryrefslogtreecommitdiffstats
path: root/apps/lib/apps.c
diff options
context:
space:
mode:
authorxkernel <xkernel.wang@foxmail.com>2022-03-07 16:06:17 +0800
committerTomas Mraz <tomas@openssl.org>2022-03-14 09:54:36 +0100
commitaef0e2a12a33068906bed1699bcb32fdcdae47ec (patch)
tree36c20c1084e443feb9508d3cebd282802ac87a44 /apps/lib/apps.c
parente1cb5bf4c61f5ac7ec354da9a3b3762c64e31332 (diff)
check return value of functions that call BIO_new() internally
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17821)
Diffstat (limited to 'apps/lib/apps.c')
-rw-r--r--apps/lib/apps.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/apps/lib/apps.c b/apps/lib/apps.c
index 07dd4550f2..e27f7ff61a 100644
--- a/apps/lib/apps.c
+++ b/apps/lib/apps.c
@@ -291,7 +291,7 @@ static char *app_get_pass(const char *arg, int keepbio)
i = atoi(arg + 3);
if (i >= 0)
pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
- if ((i < 0) || !pwdbio) {
+ if ((i < 0) || pwdbio == NULL) {
BIO_printf(bio_err, "Can't access file descriptor %s\n", arg + 3);
return NULL;
}
@@ -299,6 +299,12 @@ static char *app_get_pass(const char *arg, int keepbio)
* Can't do BIO_gets on an fd BIO so add a buffering BIO
*/
btmp = BIO_new(BIO_f_buffer());
+ if (btmp == NULL) {
+ BIO_free_all(pwdbio);
+ pwdbio = NULL;
+ BIO_printf(bio_err, "Out of memory\n");
+ return NULL;
+ }
pwdbio = BIO_push(btmp, pwdbio);
#endif
} else if (strcmp(arg, "stdin") == 0) {