summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/evp/evp_key.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index 33de513ef2..debd1b7561 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_key.c,v 1.24 2017/01/29 17:49:23 beck Exp $ */ 1/* $OpenBSD: evp_key.c,v 1.25 2018/08/14 17:51:36 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -101,17 +101,20 @@ EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt,
101 char buff[BUFSIZ]; 101 char buff[BUFSIZ];
102 UI *ui; 102 UI *ui;
103 103
104 if (len > BUFSIZ)
105 len = BUFSIZ;
106 if (min < 0 || len - 1 < min)
107 return -1;
104 if ((prompt == NULL) && (prompt_string[0] != '\0')) 108 if ((prompt == NULL) && (prompt_string[0] != '\0'))
105 prompt = prompt_string; 109 prompt = prompt_string;
106 ui = UI_new(); 110 ui = UI_new();
107 if (ui == NULL) 111 if (ui == NULL)
108 return -1; 112 return -1;
109 if (UI_add_input_string(ui, prompt, 0, buf, min, 113 if (UI_add_input_string(ui, prompt, 0, buf, min, len - 1) < 0)
110 (len >= BUFSIZ) ? BUFSIZ - 1 : len) < 0)
111 return -1; 114 return -1;
112 if (verify) { 115 if (verify) {
113 if (UI_add_verify_string(ui, prompt, 0, buff, min, 116 if (UI_add_verify_string(ui, prompt, 0, buff, min, len - 1, buf)
114 (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf) < 0) 117 < 0)
115 return -1; 118 return -1;
116 } 119 }
117 ret = UI_process(ui); 120 ret = UI_process(ui);