The branch master has been updated
       via  515480be79de6907fcf0f7797aa0d3cd45e7d33c (commit)
       via  bb19b9d4561228599b2259f6a4912066274ae622 (commit)
       via  1d8897176d06eeb88738182dbd4ad08df2f045e9 (commit)
       via  3b66592490e7b43b94298f53d4e58a611644fe4e (commit)
       via  f42b3b70d8f2b399e6a0f217bd022f38884343eb (commit)
       via  9d9691f78a67fed1b30b0cf84b2f3601897b9639 (commit)
       via  4439a6483e1579359a75f061373b377995516032 (commit)
      from  a5d250e57e88650986e8cf2dff6c698c50eb3255 (commit)


- Log -----------------------------------------------------------------
commit 515480be79de6907fcf0f7797aa0d3cd45e7d33c
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Mon Jun 14 12:58:40 2021 +0200

    ASN1_parse_dump(): allow NULL BIO input, to simplify applications not 
needing output
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

commit bb19b9d4561228599b2259f6a4912066274ae622
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Sat Jun 12 11:49:22 2021 +0200

    BIO_write_ex(): Make handing of BIO b == NULL and dlen == 0 less redundant
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

commit 1d8897176d06eeb88738182dbd4ad08df2f045e9
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Sat Jun 12 13:47:38 2021 +0200

    BIO: Make source file names in crypto/bio/ consistent
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

commit 3b66592490e7b43b94298f53d4e58a611644fe4e
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Sat Jun 12 13:41:19 2021 +0200

    BIO_dum_indent_cb(): Fix handling of cb return value
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

commit f42b3b70d8f2b399e6a0f217bd022f38884343eb
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Sat Jun 12 11:35:09 2021 +0200

    fuzz/asn1parse.c: Clean up non-portable code and catch malloc failure
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

commit 9d9691f78a67fed1b30b0cf84b2f3601897b9639
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Sat Jun 12 11:27:28 2021 +0200

    BIO: prevent crash on NULL BIO for prefix_ctrl() and thus for 
BIO_set_prefix(), BIO_set_indent(), etc.
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

commit 4439a6483e1579359a75f061373b377995516032
Author: Dr. David von Oheimb <david.von.ohe...@siemens.com>
Date:   Sat Jun 12 11:25:07 2021 +0200

    ASN1: rename asn1_par.c to asn1_parse.c for clarity; simplify asn1_parse2()
    
    Reviewed-by: Tomas Mraz <to...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15722)

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

Summary of changes:
 crypto/asn1/{asn1_par.c => asn1_parse.c}   | 28 +++++++++++-----------------
 crypto/asn1/build.info                     |  2 +-
 crypto/bio/bf_prefix.c                     |  4 ++--
 crypto/bio/{b_addr.c => bio_addr.c}        |  0
 crypto/bio/{b_dump.c => bio_dump.c}        |  7 +++++--
 crypto/bio/bio_lib.c                       |  9 ++-------
 crypto/bio/{b_print.c => bio_print.c}      |  0
 crypto/bio/{b_sock.c => bio_sock.c}        |  0
 crypto/bio/{b_sock2.c => bio_sock2.c}      |  0
 crypto/bio/build.info                      |  6 +++---
 crypto/bio/{core_bio.c => ossl_core_bio.c} |  0
 fuzz/asn1parse.c                           |  4 ++--
 12 files changed, 26 insertions(+), 34 deletions(-)
 rename crypto/asn1/{asn1_par.c => asn1_parse.c} (95%)
 rename crypto/bio/{b_addr.c => bio_addr.c} (100%)
 rename crypto/bio/{b_dump.c => bio_dump.c} (97%)
 rename crypto/bio/{b_print.c => bio_print.c} (100%)
 rename crypto/bio/{b_sock.c => bio_sock.c} (100%)
 rename crypto/bio/{b_sock2.c => bio_sock2.c} (100%)
 rename crypto/bio/{core_bio.c => ossl_core_bio.c} (100%)

diff --git a/crypto/asn1/asn1_par.c b/crypto/asn1/asn1_parse.c
similarity index 95%
rename from crypto/asn1/asn1_par.c
rename to crypto/asn1/asn1_parse.c
index 3a493de0fc..a131713d73 100644
--- a/crypto/asn1/asn1_par.c
+++ b/crypto/asn1/asn1_parse.c
@@ -41,15 +41,16 @@ static int asn1_print_info(BIO *bp, long offset, int depth, 
int hl, long len,
                          offset, depth, (long)hl, p) <= 0)
             goto err;
     }
-    if (BIO_set_prefix(bp, str) <= 0) {
-        if ((bp = BIO_push(BIO_new(BIO_f_prefix()), bp)) == NULL)
+    if (bp != NULL) {
+        if (BIO_set_prefix(bp, str) <= 0) {
+            if ((bp = BIO_push(BIO_new(BIO_f_prefix()), bp)) == NULL)
+                goto err;
+            pop_f_prefix = 1;
+        }
+        saved_indent = BIO_get_indent(bp);
+        if (BIO_set_prefix(bp, str) <= 0 || BIO_set_indent(bp, indent) < 0)
             goto err;
-        pop_f_prefix = 1;
     }
-    saved_indent = BIO_get_indent(bp);
-    if (BIO_set_prefix(bp, str) <= 0
-        || BIO_set_indent(bp, indent) < 0)
-        goto err;
 
     /*
      * BIO_set_prefix made a copy of |str|, so we can safely use it for
@@ -115,9 +116,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, 
long length,
         op = p;
         j = ASN1_get_object(&p, &len, &tag, &xclass, length);
         if (j & 0x80) {
-            if (BIO_write(bp, "Error in encoding\n", 18) <= 0)
-                goto end;
-            ret = 0;
+            BIO_puts(bp, "Error in encoding\n");
             goto end;
         }
         hl = (p - op);
@@ -136,7 +135,6 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, 
long length,
                 goto end;
             if (len > length) {
                 BIO_printf(bp, "length is greater than %ld\n", length);
-                ret = 0;
                 goto end;
             }
             if ((j == 0x21) && (len == 0)) {
@@ -144,10 +142,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, 
long length,
                     r = asn1_parse2(bp, &p, (long)(tot - p),
                                     offset + (p - *pp), depth + 1,
                                     indent, dump);
-                    if (r == 0) {
-                        ret = 0;
+                    if (r == 0)
                         goto end;
-                    }
                     if ((r == 2) || (p >= tot)) {
                         len = p - sp;
                         break;
@@ -161,10 +157,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, 
long length,
                     r = asn1_parse2(bp, &p, tmp,
                                     offset + (p - *pp), depth + 1,
                                     indent, dump);
-                    if (r == 0) {
-                        ret = 0;
+                    if (r == 0)
                         goto end;
-                    }
                     tmp -= p - sp;
                 }
             }
diff --git a/crypto/asn1/build.info b/crypto/asn1/build.info
index e10d631654..33b86fdd31 100644
--- a/crypto/asn1/build.info
+++ b/crypto/asn1/build.info
@@ -11,7 +11,7 @@ SOURCE[../../libcrypto]=\
         tasn_prn.c tasn_scn.c ameth_lib.c \
         f_int.c f_string.c \
         x_pkey.c bio_asn1.c bio_ndef.c asn_mime.c \
-        asn1_gen.c asn1_par.c asn1_lib.c asn1_err.c a_strnid.c \
+        asn1_gen.c asn1_parse.c asn1_lib.c asn1_err.c a_strnid.c \
         evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p5_scrypt.c p8_pkey.c \
         asn_moid.c asn_mstbl.c asn1_item_list.c \
         d2i_param.c
diff --git a/crypto/bio/bf_prefix.c b/crypto/bio/bf_prefix.c
index 5727c14950..c9059ca80a 100644
--- a/crypto/bio/bf_prefix.c
+++ b/crypto/bio/bf_prefix.c
@@ -151,9 +151,9 @@ static int prefix_write(BIO *b, const char *out, size_t 
outl,
 static long prefix_ctrl(BIO *b, int cmd, long num, void *ptr)
 {
     long ret = 0;
-    PREFIX_CTX *ctx = BIO_get_data(b);
+    PREFIX_CTX *ctx;
 
-    if (ctx == NULL)
+    if (b == NULL || (ctx = BIO_get_data(b)) == NULL)
         return -1;
 
     switch (cmd) {
diff --git a/crypto/bio/b_addr.c b/crypto/bio/bio_addr.c
similarity index 100%
rename from crypto/bio/b_addr.c
rename to crypto/bio/bio_addr.c
diff --git a/crypto/bio/b_dump.c b/crypto/bio/bio_dump.c
similarity index 97%
rename from crypto/bio/b_dump.c
rename to crypto/bio/bio_dump.c
index b99ebc0486..104813959c 100644
--- a/crypto/bio/b_dump.c
+++ b/crypto/bio/bio_dump.c
@@ -29,7 +29,7 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t 
len, void *u),
                        void *u, const void *v, int len, int indent)
 {
     const unsigned char *s = v;
-    int ret = 0;
+    int res, ret = 0;
     char buf[288 + 1];
     int i, j, rows, n;
     unsigned char ch;
@@ -86,7 +86,10 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t 
len, void *u),
          * if this is the last call then update the ddt_dump thing so that we
          * will move the selection point in the debug window
          */
-        ret += cb((void *)buf, n, u);
+        res = cb((void *)buf, n, u);
+        if (res < 0)
+            return res;
+        ret += res;
     }
     return ret;
 }
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index af7ad05bca..a378f186d7 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -393,13 +393,8 @@ int BIO_write(BIO *b, const void *data, int dlen)
 
 int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written)
 {
-    if (dlen == 0) {
-        /* no error */
-        if (written != NULL)
-            *written = 0;
-        return 1;
-    }
-    return bio_write_intern(b, data, dlen, written) > 0;
+    return bio_write_intern(b, data, dlen, written) > 0
+        || (b != NULL && dlen == 0); /* order is important for *written */
 }
 
 int BIO_puts(BIO *b, const char *buf)
diff --git a/crypto/bio/b_print.c b/crypto/bio/bio_print.c
similarity index 100%
rename from crypto/bio/b_print.c
rename to crypto/bio/bio_print.c
diff --git a/crypto/bio/b_sock.c b/crypto/bio/bio_sock.c
similarity index 100%
rename from crypto/bio/b_sock.c
rename to crypto/bio/bio_sock.c
diff --git a/crypto/bio/b_sock2.c b/crypto/bio/bio_sock2.c
similarity index 100%
rename from crypto/bio/b_sock2.c
rename to crypto/bio/bio_sock2.c
diff --git a/crypto/bio/build.info b/crypto/bio/build.info
index ba7e358c29..b203ed5e63 100644
--- a/crypto/bio/build.info
+++ b/crypto/bio/build.info
@@ -3,9 +3,9 @@ LIBS=../../libcrypto
 # Base library
 SOURCE[../../libcrypto]=\
         bio_lib.c bio_cb.c bio_err.c \
-        b_print.c b_dump.c b_addr.c \
-        b_sock.c b_sock2.c \
-        bio_meth.c core_bio.c
+        bio_print.c bio_dump.c bio_addr.c \
+        bio_sock.c bio_sock2.c \
+        bio_meth.c ossl_core_bio.c
 
 # Source / sink implementations
 SOURCE[../../libcrypto]=\
diff --git a/crypto/bio/core_bio.c b/crypto/bio/ossl_core_bio.c
similarity index 100%
rename from crypto/bio/core_bio.c
rename to crypto/bio/ossl_core_bio.c
diff --git a/fuzz/asn1parse.c b/fuzz/asn1parse.c
index 72b0df8a46..7401375bf0 100644
--- a/fuzz/asn1parse.c
+++ b/fuzz/asn1parse.c
@@ -23,9 +23,9 @@ static BIO *bio_out;
 
 int FuzzerInitialize(int *argc, char ***argv)
 {
-    bio_out = BIO_new_file("/dev/null", "w");
+    bio_out = BIO_new(BIO_s_null()); /* output will be ignored */
     if (bio_out == NULL)
-        bio_out = BIO_new(BIO_s_mem());
+        return 0;
     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);

Reply via email to