summaryrefslogtreecommitdiff
path: root/crypto/ui/ui_util.c
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2023-05-13 09:04:18 +0200
committerTomas Mraz <tomas@openssl.org>2023-05-17 12:08:34 +0200
commit5d6f13d90d5c4212737002bcd54871cf236a1220 (patch)
tree7e0e2db4890b3834c6cc4957262ec95ec9e13995 /crypto/ui/ui_util.c
parent96cb0d9217b800985cb88aa34fdbc023c9e84a18 (diff)
downloadopenssl-new-openssl-3.0.tar.gz
Fix stack corruption in ui_readopenssl-3.0
This is an alternative to #20893 Additionally this fixes also a possible issue in UI_UTIL_read_pw: When UI_new returns NULL, the result code would still be zero as if UI_UTIL_read_pw succeeded, but the password buffer is left uninitialized, with subsequent possible stack corruption or worse. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20957) (cherry picked from commit a64c48cff88e032cf9513578493c4536df725a22)
Diffstat (limited to 'crypto/ui/ui_util.c')
-rw-r--r--crypto/ui/ui_util.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c
index 80297969ab..e26c1b5d25 100644
--- a/crypto/ui/ui_util.c
+++ b/crypto/ui/ui_util.c
@@ -32,7 +32,7 @@ int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
int verify)
{
- int ok = 0;
+ int ok = -2;
UI *ui;
if (size < 1)
@@ -47,8 +47,6 @@ int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
ok = UI_process(ui);
UI_free(ui);
}
- if (ok > 0)
- ok = 0;
return ok;
}