[openssl] master update

tomas at openssl.org tomas at openssl.org
Tue Aug 31 10:20:47 UTC 2021


The branch master has been updated
       via  2bdab81198ae366d25547b1441609c7d324b0bb4 (commit)
       via  3f7ad402b06fd75397f11fd9f0b2ad6778a31f99 (commit)
       via  72a509f94fc2be80c9903b7512715cd526a82e25 (commit)
      from  69222552252c86e7d68dcc24b2ce1aa0793ab3aa (commit)


- Log -----------------------------------------------------------------
commit 2bdab81198ae366d25547b1441609c7d324b0bb4
Author: Tomas Mraz <tomas at openssl.org>
Date:   Tue Aug 31 09:05:59 2021 +0200

    apps/pkcs12: Do not assume null termination of ASN1_UTF8STRING
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/16433)

commit 3f7ad402b06fd75397f11fd9f0b2ad6778a31f99
Author: Tomas Mraz <tomas at openssl.org>
Date:   Thu Aug 26 15:13:58 2021 +0200

    ci: Add -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to asan build
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/16433)

commit 72a509f94fc2be80c9903b7512715cd526a82e25
Author: Tomas Mraz <tomas at openssl.org>
Date:   Thu Aug 26 15:08:15 2021 +0200

    Make the -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION pass tests
    
    Fixes #16428
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/16433)

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

Summary of changes:
 .github/workflows/ci.yml |  2 +-
 apps/pkcs12.c            |  3 ++-
 crypto/asn1/a_print.c    |  7 ++++---
 crypto/asn1/asn1_lib.c   | 11 ++++++++---
 ssl/ssl_asn1.c           |  2 +-
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bcb5cd5775..2f2a9b9fb2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -130,7 +130,7 @@ jobs:
     steps:
     - uses: actions/checkout at v2
     - name: config
-      run: ./config --banner=Configured --debug enable-asan enable-ubsan enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-fips && perl configdata.pm --dump
+      run: ./config --banner=Configured --debug enable-asan enable-ubsan enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-fips -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION && perl configdata.pm --dump
     - name: make
       run: make -s -j4
     - name: make test
diff --git a/apps/pkcs12.c b/apps/pkcs12.c
index d745df8494..dcb173f201 100644
--- a/apps/pkcs12.c
+++ b/apps/pkcs12.c
@@ -1142,7 +1142,8 @@ void print_attribute(BIO *out, const ASN1_TYPE *av)
         break;
 
     case V_ASN1_UTF8STRING:
-        BIO_printf(out, "%s\n", av->value.utf8string->data);
+        BIO_printf(out, "%.*s\n", av->value.utf8string->length,
+                   av->value.utf8string->data);
         break;
 
     case V_ASN1_OCTET_STRING:
diff --git a/crypto/asn1/a_print.c b/crypto/asn1/a_print.c
index 328e0abcc5..e04f9b1f2e 100644
--- a/crypto/asn1/a_print.c
+++ b/crypto/asn1/a_print.c
@@ -18,12 +18,13 @@ int ASN1_PRINTABLE_type(const unsigned char *s, int len)
     int ia5 = 0;
     int t61 = 0;
 
-    if (len <= 0)
-        len = -1;
     if (s == NULL)
         return V_ASN1_PRINTABLESTRING;
 
-    while ((*s) && (len-- != 0)) {
+    if (len < 0)
+        len = strlen((const char *)s);
+
+    while (len-- > 0) {
         c = *(s++);
         if (!ossl_isasn1print(c))
             ia5 = 1;
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 02c34a4438..5359cbc117 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -303,7 +303,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in)
         c = str->data;
 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
         /* No NUL terminator in fuzzing builds */
-        str->data = OPENSSL_realloc(c, len);
+        str->data = OPENSSL_realloc(c, len != 0 ? len : 1);
 #else
         str->data = OPENSSL_realloc(c, len + 1);
 #endif
@@ -316,7 +316,11 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in)
     str->length = len;
     if (data != NULL) {
         memcpy(str->data, data, len);
-#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+        /* Set the unused byte to something non NUL and printable. */
+        if (len == 0)
+            str->data[len] = '~';
+#else
         /*
          * Add a NUL terminator. This should not be necessary - but we add it as
          * a safety precaution
@@ -384,7 +388,8 @@ int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
 
     i = (a->length - b->length);
     if (i == 0) {
-        i = memcmp(a->data, b->data, a->length);
+        if (a->length != 0)
+            i = memcmp(a->data, b->data, a->length);
         if (i == 0)
             return a->type - b->type;
         else
diff --git a/ssl/ssl_asn1.c b/ssl/ssl_asn1.c
index 2cbd95fa1b..3503fdc210 100644
--- a/ssl/ssl_asn1.c
+++ b/ssl/ssl_asn1.c
@@ -229,7 +229,7 @@ static int ssl_session_strndup(char **pdst, ASN1_OCTET_STRING *src)
 static int ssl_session_memcpy(unsigned char *dst, size_t *pdstlen,
                               ASN1_OCTET_STRING *src, size_t maxlen)
 {
-    if (src == NULL) {
+    if (src == NULL || src->length == 0) {
         *pdstlen = 0;
         return 1;
     }


More information about the openssl-commits mailing list