Two buffers used for username/password prompting can be moved into a
deeper block so that they don't get set if they are not going to be
used.
---
src/openvpn/misc.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index a9259f0..e0aa5f9 100644
--- a/src/openvpn/misc.c
+++ b/src/openvpn/misc.c
@@ -1165,22 +1165,23 @@ get_user_pass_cr (struct user_pass *up,
else
#endif
{
- struct buffer user_prompt = alloc_buf_gc (128, &gc);
- struct buffer pass_prompt = alloc_buf_gc (128, &gc);
-
- buf_printf (&user_prompt, "Enter %s Username:", prefix);
- buf_printf (&pass_prompt, "Enter %s Password:", prefix);
-
if (username_from_stdin && !(flags & GET_USER_PASS_PASSWORD_ONLY))
{
+ struct buffer user_prompt = alloc_buf_gc (128, &gc);
+ buf_printf (&user_prompt, "Enter %s Username:", prefix);
if (!get_console_input (BSTR (&user_prompt), true,
up->username, USER_PASS_LEN))
msg (M_FATAL, "ERROR: could not read %s username from
stdin", prefix);
if (strlen (up->username) == 0)
msg (M_FATAL, "ERROR: %s username is empty", prefix);
}
- if (password_from_stdin && !get_console_input (BSTR
(&pass_prompt), false, up->password, USER_PASS_LEN))
- msg (M_FATAL, "ERROR: could not not read %s password from
stdin", prefix);
+ if (password_from_stdin)
+ {
+ struct buffer pass_prompt = alloc_buf_gc (128, &gc);
+ buf_printf (&pass_prompt, "Enter %s Password:", prefix);
+ if (!get_console_input (BSTR (&pass_prompt), false,
up->password, USER_PASS_LEN))
+ msg (M_FATAL, "ERROR: could not not read %s password from
stdin", prefix);
+ }
#ifdef ENABLE_CLIENT_CR
if (auth_challenge && (flags & GET_USER_PASS_STATIC_CHALLENGE))
--
1.9.1