Fix the checks of UI_add_input_string
authorPeiwei Hu <jlu.hpw@foxmail.com>
Sat, 28 May 2022 16:02:37 +0000 (00:02 +0800)
committerTodd Short <todd.short@me.com>
Thu, 2 Jun 2022 14:36:56 +0000 (10:36 -0400)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

engines/e_loader_attic.c
test/uitest.c

index c7ab4251c0597f7fe8b1087c0742a7f24d2238fa..7b9dcd9fee6d04e9e906c7cef7fa8e01674b13ff 100644 (file)
@@ -70,8 +70,8 @@ static char *file_get_pass(const UI_METHOD *ui_method, char *pass,
     if ((prompt = UI_construct_prompt(ui, desc, info)) == NULL) {
         ATTICerr(0, ERR_R_MALLOC_FAILURE);
         pass = NULL;
-    } else if (!UI_add_input_string(ui, prompt, UI_INPUT_FLAG_DEFAULT_PWD,
-                                    pass, 0, maxsize - 1)) {
+    } else if (UI_add_input_string(ui, prompt, UI_INPUT_FLAG_DEFAULT_PWD,
+                                    pass, 0, maxsize - 1) <= 0) {
         ATTICerr(0, ERR_R_UI_LIB);
         pass = NULL;
     } else {
index 8659b0b4bed75fdcb14e5a548fb6c720fcf6f419..82c8c59204f49adf7ba5c51e4dbffc905ec54a74 100644 (file)
@@ -44,8 +44,8 @@ static int test_old(void)
     /* The wrapper passes the UI userdata as the callback userdata param */
     UI_add_user_data(ui, defpass);
 
-    if (!UI_add_input_string(ui, "prompt", UI_INPUT_FLAG_DEFAULT_PWD,
-                             pass, 0, sizeof(pass) - 1))
+    if (UI_add_input_string(ui, "prompt", UI_INPUT_FLAG_DEFAULT_PWD,
+                             pass, 0, sizeof(pass) - 1) <= 0)
         goto err;
 
     switch (UI_process(ui)) {