[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Jun 28 12:24:35 UTC 2017


The branch master has been updated
       via  a2755b1695e8f58c3b531a53058aba5146ea075b (commit)
       via  3816be5d4a6a1f17dc4b7d398c42398c48e62e1a (commit)
      from  e041f3b8baf3b9a2d57f5eb818a6b0aebd96e953 (commit)


- Log -----------------------------------------------------------------
commit a2755b1695e8f58c3b531a53058aba5146ea075b
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Jun 28 13:01:29 2017 +0200

    test/uitest.c's pem_password_cb returned 1 instead of the password length
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3791)

commit 3816be5d4a6a1f17dc4b7d398c42398c48e62e1a
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Jun 28 11:17:24 2017 +0200

    UI_UTIL_wrap_read_pem_callback: make sure to terminate the string received
    
    The callback we're wrapping around may or may not return a
    NUL-terminated string.  Let's ensure it is.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3791)

-----------------------------------------------------------------------

Summary of changes:
 crypto/ui/ui_util.c | 4 +++-
 test/uitest.c       | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c
index 67b2ec2..dbfeecc 100644
--- a/crypto/ui/ui_util.c
+++ b/crypto/ui/ui_util.c
@@ -104,7 +104,7 @@ static int ui_read(UI *ui, UI_STRING *uis)
     switch (UI_get_string_type(uis)) {
     case UIT_PROMPT:
         {
-            char result[PEM_BUFSIZE];
+            char result[PEM_BUFSIZE + 1];
             const struct pem_password_cb_data *data =
                 UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);
             int maxsize = UI_get_result_maxsize(uis);
@@ -112,6 +112,8 @@ static int ui_read(UI *ui, UI_STRING *uis)
                                maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize,
                                data->rwflag, UI_get0_user_data(ui));
 
+            if (len >= 0)
+                result[len] = '\0';
             if (len <= 0)
                 return len;
             if (UI_set_result(ui, uis, result) >= 0)
diff --git a/test/uitest.c b/test/uitest.c
index 68b4b8c..469e230 100644
--- a/test/uitest.c
+++ b/test/uitest.c
@@ -24,7 +24,7 @@ char *default_config_file = NULL;
 static int test_pem_password_cb(char *buf, int size, int rwflag, void *userdata)
 {
     OPENSSL_strlcpy(buf, (char *)userdata, (size_t)size);
-    return 1;
+    return strlen(buf);
 }
 
 /*


More information about the openssl-commits mailing list