- Removes unused field prompt_len
- Change field reponse_len to int since that
is what the code actually expects. Most callers
user a constant either way.
Change-Id: I04542e678f81d5d4a853b4370d9b8adc4dac1212
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1216
Message-Id: <20251010094753.2825-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59244794/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -53,14 +53,14 @@ query_user_clear(void) |
| 53 | 53 |
|
| 54 | 54 |
|
| 55 | 55 |
void |
| 56 |
-query_user_add(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo) |
|
| 56 |
+query_user_add(char *prompt, char *resp, int resp_len, bool echo) |
|
| 57 | 57 |
{
|
| 58 | 58 |
int i; |
| 59 | 59 |
|
| 60 | 60 |
/* Ensure input is sane. All these must be present otherwise it is |
| 61 | 61 |
* a programming error. |
| 62 | 62 |
*/ |
| 63 |
- ASSERT(prompt_len > 0 && prompt != NULL && resp_len > 0 && resp != NULL); |
|
| 63 |
+ ASSERT(prompt != NULL && resp_len > 0 && resp != NULL); |
|
| 64 | 64 |
|
| 65 | 65 |
/* Seek to the last unused slot */ |
| 66 | 66 |
for (i = 0; i < QUERY_USER_NUMSLOTS; i++) |
| ... | ... |
@@ -74,7 +74,6 @@ query_user_add(char *prompt, size_t prompt_len, char *resp, size_t resp_len, boo |
| 74 | 74 |
|
| 75 | 75 |
/* Save the information needed for the user interaction */ |
| 76 | 76 |
query_user[i].prompt = prompt; |
| 77 |
- query_user[i].prompt_len = prompt_len; |
|
| 78 | 77 |
query_user[i].response = resp; |
| 79 | 78 |
query_user[i].response_len = resp_len; |
| 80 | 79 |
query_user[i].echo = echo; |
| ... | ... |
@@ -32,11 +32,10 @@ |
| 32 | 32 |
*/ |
| 33 | 33 |
struct _query_user |
| 34 | 34 |
{
|
| 35 |
- char *prompt; /**< Prompt to present to the user */ |
|
| 36 |
- size_t prompt_len; /**< Length of the prompt string */ |
|
| 37 |
- char *response; /**< The user's response */ |
|
| 38 |
- size_t response_len; /**< Length the of the user response */ |
|
| 39 |
- bool echo; /**< True: The user should see what is being typed, otherwise mask it */ |
|
| 35 |
+ char *prompt; /**< Prompt to present to the user */ |
|
| 36 |
+ char *response; /**< The user's response */ |
|
| 37 |
+ int response_len; /**< Length the of the user response */ |
|
| 38 |
+ bool echo; /**< True: The user should see what is being typed, otherwise mask it */ |
|
| 40 | 39 |
}; |
| 41 | 40 |
|
| 42 | 41 |
#define QUERY_USER_NUMSLOTS 10 |
| ... | ... |
@@ -53,13 +52,12 @@ void query_user_clear(void); |
| 53 | 53 |
* Adds an item to ask the user for |
| 54 | 54 |
* |
| 55 | 55 |
* @param prompt Prompt to display to the user |
| 56 |
- * @param prompt_len Length of the prompt string |
|
| 57 | 56 |
* @param resp String containing the user response |
| 58 | 57 |
* @param resp_len Length of the response string |
| 59 | 58 |
* @param echo Should the user input be echoed to the user? If False, input will be masked |
| 60 | 59 |
* |
| 61 | 60 |
*/ |
| 62 |
-void query_user_add(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo); |
|
| 61 |
+void query_user_add(char *prompt, char *resp, int resp_len, bool echo); |
|
| 63 | 62 |
|
| 64 | 63 |
|
| 65 | 64 |
/** |
| ... | ... |
@@ -117,10 +115,10 @@ query_user_exec(void) |
| 117 | 117 |
* |
| 118 | 118 |
*/ |
| 119 | 119 |
static inline bool |
| 120 |
-query_user_SINGLE(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo) |
|
| 120 |
+query_user_SINGLE(char *prompt, char *resp, int resp_len, bool echo) |
|
| 121 | 121 |
{
|
| 122 | 122 |
query_user_clear(); |
| 123 |
- query_user_add(prompt, prompt_len, resp, resp_len, echo); |
|
| 123 |
+ query_user_add(prompt, resp, resp_len, echo); |
|
| 124 | 124 |
return query_user_exec(); |
| 125 | 125 |
} |
| 126 | 126 |
|
| ... | ... |
@@ -45,11 +45,6 @@ |
| 45 | 45 |
|
| 46 | 46 |
#include "win32.h" |
| 47 | 47 |
|
| 48 |
-#if defined(__GNUC__) || defined(__clang__) |
|
| 49 |
-#pragma GCC diagnostic push |
|
| 50 |
-#pragma GCC diagnostic ignored "-Wconversion" |
|
| 51 |
-#endif |
|
| 52 |
- |
|
| 53 | 48 |
/** |
| 54 | 49 |
* Get input from a Windows console. |
| 55 | 50 |
* |
| ... | ... |
@@ -73,7 +68,7 @@ get_console_input_win32(const char *prompt, const bool echo, char *input, const |
| 73 | 73 |
HANDLE in = GetStdHandle(STD_INPUT_HANDLE); |
| 74 | 74 |
int orig_stderr = get_orig_stderr(); /* guaranteed to be always valid */ |
| 75 | 75 |
if ((in == INVALID_HANDLE_VALUE) || win32_service_interrupt(&win32_signal) |
| 76 |
- || (_write(orig_stderr, prompt, strlen(prompt)) == -1)) |
|
| 76 |
+ || (_write(orig_stderr, prompt, (unsigned int)strlen(prompt)) == -1)) |
|
| 77 | 77 |
{
|
| 78 | 78 |
msg(M_WARN | M_ERRNO, "get_console_input_win32(): unexpected error"); |
| 79 | 79 |
return false; |
| ... | ... |
@@ -139,10 +134,6 @@ get_console_input_win32(const char *prompt, const bool echo, char *input, const |
| 139 | 139 |
return false; |
| 140 | 140 |
} |
| 141 | 141 |
|
| 142 |
-#if defined(__GNUC__) || defined(__clang__) |
|
| 143 |
-#pragma GCC diagnostic pop |
|
| 144 |
-#endif |
|
| 145 |
- |
|
| 146 | 142 |
#endif /* _WIN32 */ |
| 147 | 143 |
|
| 148 | 144 |
|
| ... | ... |
@@ -273,11 +264,6 @@ get_console_input(const char *prompt, const bool echo, char *input, const int ca |
| 273 | 273 |
return ret; |
| 274 | 274 |
} |
| 275 | 275 |
|
| 276 |
-#if defined(__GNUC__) || defined(__clang__) |
|
| 277 |
-#pragma GCC diagnostic push |
|
| 278 |
-#pragma GCC diagnostic ignored "-Wconversion" |
|
| 279 |
-#endif |
|
| 280 |
- |
|
| 281 | 276 |
/** |
| 282 | 277 |
* @copydoc query_user_exec() |
| 283 | 278 |
* |
| ... | ... |
@@ -309,7 +295,3 @@ query_user_exec_builtin(void) |
| 309 | 309 |
|
| 310 | 310 |
return ret; |
| 311 | 311 |
} |
| 312 |
- |
|
| 313 |
-#if defined(__GNUC__) || defined(__clang__) |
|
| 314 |
-#pragma GCC diagnostic pop |
|
| 315 |
-#endif |
| ... | ... |
@@ -239,8 +239,7 @@ get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix |
| 239 | 239 |
struct buffer user_prompt = alloc_buf_gc(128, &gc); |
| 240 | 240 |
|
| 241 | 241 |
buf_printf(&user_prompt, "NEED-OK|%s|%s:", prefix, up->username); |
| 242 |
- if (!query_user_SINGLE(BSTR(&user_prompt), BLEN(&user_prompt), up->password, |
|
| 243 |
- USER_PASS_LEN, false)) |
|
| 242 |
+ if (!query_user_SINGLE(BSTR(&user_prompt), up->password, USER_PASS_LEN, false)) |
|
| 244 | 243 |
{
|
| 245 | 244 |
msg(M_FATAL, "ERROR: could not read %s ok-confirmation from stdin", prefix); |
| 246 | 245 |
} |
| ... | ... |
@@ -362,7 +361,7 @@ get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix |
| 362 | 362 |
buf_printf(&challenge, "CHALLENGE: %s", ac->challenge_text); |
| 363 | 363 |
buf_set_write(&packed_resp, (uint8_t *)up->password, USER_PASS_LEN); |
| 364 | 364 |
|
| 365 |
- if (!query_user_SINGLE(BSTR(&challenge), BLEN(&challenge), response, |
|
| 365 |
+ if (!query_user_SINGLE(BSTR(&challenge), response, |
|
| 366 | 366 |
USER_PASS_LEN, BOOL_CAST(ac->flags & CR_ECHO))) |
| 367 | 367 |
{
|
| 368 | 368 |
msg(M_FATAL, "ERROR: could not read challenge response from stdin"); |
| ... | ... |
@@ -387,14 +386,12 @@ get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix |
| 387 | 387 |
|
| 388 | 388 |
if (username_from_stdin && !(flags & GET_USER_PASS_PASSWORD_ONLY)) |
| 389 | 389 |
{
|
| 390 |
- query_user_add(BSTR(&user_prompt), BLEN(&user_prompt), up->username, |
|
| 391 |
- USER_PASS_LEN, true); |
|
| 390 |
+ query_user_add(BSTR(&user_prompt), up->username, USER_PASS_LEN, true); |
|
| 392 | 391 |
} |
| 393 | 392 |
|
| 394 | 393 |
if (password_from_stdin) |
| 395 | 394 |
{
|
| 396 |
- query_user_add(BSTR(&pass_prompt), BLEN(&pass_prompt), up->password, |
|
| 397 |
- USER_PASS_LEN, false); |
|
| 395 |
+ query_user_add(BSTR(&pass_prompt), up->password, USER_PASS_LEN, false); |
|
| 398 | 396 |
} |
| 399 | 397 |
|
| 400 | 398 |
if (!query_user_exec()) |
| ... | ... |
@@ -421,8 +418,7 @@ get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix |
| 421 | 421 |
challenge = alloc_buf_gc(14 + strlen(auth_challenge), &gc); |
| 422 | 422 |
buf_printf(&challenge, "CHALLENGE: %s", auth_challenge); |
| 423 | 423 |
|
| 424 |
- if (!query_user_SINGLE(BSTR(&challenge), BLEN(&challenge), response, |
|
| 425 |
- USER_PASS_LEN, |
|
| 424 |
+ if (!query_user_SINGLE(BSTR(&challenge), response, USER_PASS_LEN, |
|
| 426 | 425 |
BOOL_CAST(flags & GET_USER_PASS_STATIC_CHALLENGE_ECHO))) |
| 427 | 426 |
{
|
| 428 | 427 |
msg(M_FATAL, "ERROR: could not retrieve static challenge response"); |
| ... | ... |
@@ -671,7 +671,7 @@ _pkcs11_openvpn_show_pkcs11_ids_pin_prompt(void *const global_data, void *const |
| 671 | 671 |
ASSERT(token != NULL); |
| 672 | 672 |
|
| 673 | 673 |
buf_printf(&pass_prompt, "Please enter '%s' token PIN or 'cancel': ", token->display); |
| 674 |
- if (!query_user_SINGLE(BSTR(&pass_prompt), BLEN(&pass_prompt), pin, pin_max, false)) |
|
| 674 |
+ if (!query_user_SINGLE(BSTR(&pass_prompt), pin, (int)pin_max, false)) |
|
| 675 | 675 |
{
|
| 676 | 676 |
msg(M_FATAL, "Could not retrieve the PIN"); |
| 677 | 677 |
} |