[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Mon Jul 25 17:52:47 UTC 2016


The branch master has been updated
       via  9d7bfb14dd22c372d6583c20583cbf9aea4cc033 (commit)
      from  78a01b3f69f563a1577a6f90edbd9ebde80d6b70 (commit)


- Log -----------------------------------------------------------------
commit 9d7bfb14dd22c372d6583c20583cbf9aea4cc033
Author: FdaSilvaYY <fdasilvayy at gmail.com>
Date:   Fri Jun 10 23:28:44 2016 +0200

    Discard BIO_set(BIO* bio) method
    
    Simplify BIO init using OPENSSL_zalloc().
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1261)

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

Summary of changes:
 crypto/bio/bio_err.c        |  1 -
 crypto/bio/bio_lib.c        | 48 +++++++++++++++------------------------------
 doc/crypto/BIO_meth_new.pod |  2 +-
 doc/crypto/BIO_new.pod      |  9 ++++++---
 include/openssl/bio.h       |  2 --
 util/libcrypto.num          |  2 +-
 6 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/crypto/bio/bio_err.c b/crypto/bio/bio_err.c
index d032ded..8f88cb9 100644
--- a/crypto/bio/bio_err.c
+++ b/crypto/bio/bio_err.c
@@ -43,7 +43,6 @@ static ERR_STRING_DATA BIO_str_functs[] = {
     {ERR_FUNC(BIO_F_BIO_PARSE_HOSTSERV), "BIO_parse_hostserv"},
     {ERR_FUNC(BIO_F_BIO_PUTS), "BIO_puts"},
     {ERR_FUNC(BIO_F_BIO_READ), "BIO_read"},
-    {ERR_FUNC(BIO_F_BIO_SET), "BIO_set"},
     {ERR_FUNC(BIO_F_BIO_SOCKET), "BIO_socket"},
     {ERR_FUNC(BIO_F_BIO_SOCKET_NBIO), "BIO_socket_nbio"},
     {ERR_FUNC(BIO_F_BIO_SOCK_INFO), "BIO_sock_info"},
diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c
index 0b111c6..98f3707 100644
--- a/crypto/bio/bio_lib.c
+++ b/crypto/bio/bio_lib.c
@@ -12,58 +12,42 @@
 #include <openssl/crypto.h>
 #include "bio_lcl.h"
 #include "internal/cryptlib.h"
-#include <openssl/stack.h>
 
 BIO *BIO_new(const BIO_METHOD *method)
 {
-    BIO *ret = OPENSSL_malloc(sizeof(*ret));
+    BIO *bio = OPENSSL_zalloc(sizeof(*bio));
 
-    if (ret == NULL) {
+    if (bio == NULL) {
         BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
         return (NULL);
     }
-    if (!BIO_set(ret, method)) {
-        OPENSSL_free(ret);
-        ret = NULL;
-    }
-    return (ret);
-}
 
-int BIO_set(BIO *bio, const BIO_METHOD *method)
-{
     bio->method = method;
-    bio->callback = NULL;
-    bio->cb_arg = NULL;
-    bio->init = 0;
     bio->shutdown = 1;
-    bio->flags = 0;
-    bio->retry_reason = 0;
-    bio->num = 0;
-    bio->ptr = NULL;
-    bio->prev_bio = NULL;
-    bio->next_bio = NULL;
     bio->references = 1;
-    bio->num_read = 0L;
-    bio->num_write = 0L;
+
     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data))
-        return 0;
+        goto err;
 
     bio->lock = CRYPTO_THREAD_lock_new();
     if (bio->lock == NULL) {
-        BIOerr(BIO_F_BIO_SET, ERR_R_MALLOC_FAILURE);
+        BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
         CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
-        return 0;
+        goto err;
     }
 
-    if (method->create != NULL) {
-        if (!method->create(bio)) {
-            CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
-            CRYPTO_THREAD_lock_free(bio->lock);
-            return 0;
-        }
+    if (method->create != NULL && !method->create(bio)) {
+        BIOerr(BIO_F_BIO_NEW, ERR_R_INIT_FAIL);
+        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
+        CRYPTO_THREAD_lock_free(bio->lock);
+        goto err;
     }
 
-    return 1;
+    return bio;
+
+err:
+    OPENSSL_free(bio);
+    return NULL;
 }
 
 int BIO_free(BIO *a)
diff --git a/doc/crypto/BIO_meth_new.pod b/doc/crypto/BIO_meth_new.pod
index 2c2db6f..65e48cb 100644
--- a/doc/crypto/BIO_meth_new.pod
+++ b/doc/crypto/BIO_meth_new.pod
@@ -88,7 +88,7 @@ BIO_ctrl().
 
 BIO_meth_get_create() and BIO_meth_set_create() get and set the function used
 for creating a new instance of the BIO respectively. This function will be
-called in response to the application calling BIO_new() or BIO_set() and passing
+called in response to the application calling BIO_new() and passing
 in a pointer to the current BIO_METHOD. The BIO_new() function will allocate the
 memory for the new BIO, and a pointer to this newly allocated structure will
 be passed as a parameter to the function.
diff --git a/doc/crypto/BIO_new.pod b/doc/crypto/BIO_new.pod
index 226f13f..006cf59 100644
--- a/doc/crypto/BIO_new.pod
+++ b/doc/crypto/BIO_new.pod
@@ -2,7 +2,8 @@
 
 =head1 NAME
 
-BIO_new, BIO_set, BIO_up_ref, BIO_free, BIO_vfree, BIO_free_all - BIO allocation and freeing functions
+BIO_new, BIO_up_ref, BIO_free, BIO_vfree, BIO_free_all,
+BIO_set - BIO allocation and freeing functions
 
 =head1 SYNOPSIS
 
@@ -19,8 +20,6 @@ BIO_new, BIO_set, BIO_up_ref, BIO_free, BIO_vfree, BIO_free_all - BIO allocation
 
 The BIO_new() function returns a new BIO using method B<type>.
 
-BIO_set() sets the method of an already existing BIO.
-
 BIO_up_ref() increments the reference count associated with the BIO object.
 
 BIO_free() frees up a single BIO, BIO_vfree() also frees up a single BIO
@@ -51,6 +50,10 @@ in a memory leak.
 Calling BIO_free_all() on a single BIO has the same effect as calling BIO_free()
 on it other than the discarded return value.
 
+=head1 HISTORY
+
+BIO_set() was removed in OpenSSL 1.1.0 as BIO type is now opaque.
+
 =head1 EXAMPLE
 
 Create a memory BIO:
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index ed50139..f847348 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -533,7 +533,6 @@ BIO *BIO_new_file(const char *filename, const char *mode);
 BIO *BIO_new_fp(FILE *stream, int close_flag);
 # endif
 BIO *BIO_new(const BIO_METHOD *type);
-int BIO_set(BIO *a, const BIO_METHOD *type);
 int BIO_free(BIO *a);
 void BIO_set_data(BIO *a, void *ptr);
 void *BIO_get_data(BIO *a);
@@ -792,7 +791,6 @@ int ERR_load_BIO_strings(void);
 # define BIO_F_BIO_PARSE_HOSTSERV                         136
 # define BIO_F_BIO_PUTS                                   110
 # define BIO_F_BIO_READ                                   111
-# define BIO_F_BIO_SET                                    143
 # define BIO_F_BIO_SOCKET                                 140
 # define BIO_F_BIO_SOCKET_NBIO                            142
 # define BIO_F_BIO_SOCK_INFO                              141
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 1fb7cf3..22f76f4 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -2805,7 +2805,7 @@ OPENSSL_init                            2761	1_1_0	EXIST::FUNCTION:
 TS_RESP_get_tst_info                    2762	1_1_0	EXIST::FUNCTION:TS
 X509_VERIFY_PARAM_get_depth             2763	1_1_0	EXIST::FUNCTION:
 EVP_SealFinal                           2764	1_1_0	EXIST::FUNCTION:RSA
-BIO_set                                 2765	1_1_0	EXIST::FUNCTION:
+BIO_set                                 2765	1_1_0	NOEXIST::FUNCTION:
 CONF_imodule_set_flags                  2766	1_1_0	EXIST::FUNCTION:
 i2d_ASN1_SET_ANY                        2767	1_1_0	EXIST::FUNCTION:
 EVP_PKEY_decrypt                        2768	1_1_0	EXIST::FUNCTION:


More information about the openssl-commits mailing list