summaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-03-04 17:49:51 +0000
committerMatt Caswell <matt@openssl.org>2015-03-05 09:09:57 +0000
commit918bb8652969fd53f0c390c1cd909265ed502c7e (patch)
tree883afa725e4529a992611b5b02e8b5c784463e99 /apps/apps.c
parent618be04e407a7800a7198ac87fa5e8cee7c6e10b (diff)
Unchecked malloc fixes
Miscellaneous unchecked malloc fixes. Also fixed some mem leaks on error paths as I spotted them along the way. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 8412e24687..233d382cd5 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -576,6 +576,11 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
char *prompt = NULL;
prompt = UI_construct_prompt(ui, "pass phrase", prompt_info);
+ if(!prompt) {
+ BIO_printf(bio_err, "Out of memory\n");
+ UI_free(ui);
+ return 0;
+ }
ui_flags |= UI_INPUT_FLAG_DEFAULT_PWD;
UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0);
@@ -585,6 +590,12 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
PW_MIN_LENGTH, bufsiz - 1);
if (ok >= 0 && verify) {
buff = (char *)OPENSSL_malloc(bufsiz);
+ if(!buff) {
+ BIO_printf(bio_err, "Out of memory\n");
+ UI_free(ui);
+ OPENSSL_free(prompt);
+ return 0;
+ }
ok = UI_add_verify_string(ui, prompt, ui_flags, buff,
PW_MIN_LENGTH, bufsiz - 1, buf);
}