[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Sun Feb 14 22:36:17 UTC 2016


The branch master has been updated
       via  d9d8e7a9c150dea538ceffe4cac6140e46389986 (commit)
      from  0756592b60d7d2bcb64f7ca01ec1430c43b1cf26 (commit)


- Log -----------------------------------------------------------------
commit d9d8e7a9c150dea538ceffe4cac6140e46389986
Author: Rich Salz <rsalz at akamai.com>
Date:   Sun Feb 14 15:50:13 2016 -0500

    Make the BIO_ADDR param optional.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

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

Summary of changes:
 crypto/bio/b_sock.c  | 15 ++++-----------
 crypto/bio/b_sock2.c |  4 +++-
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index eece85b..50bd27d 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -316,16 +316,10 @@ int BIO_get_accept_socket(char *host, int bind_mode)
 
 int BIO_accept(int sock, char **ip_port)
 {
-    BIO_ADDR *res = BIO_ADDR_new();
+    BIO_ADDR res;
     int ret = -1;
 
-    if (res == NULL) {
-        BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
-        return ret;
-    }
-
-    ret = BIO_accept_ex(sock, res, 0);
-
+    ret = BIO_accept_ex(sock, &res, 0);
     if (ret == (int)INVALID_SOCKET) {
         if (BIO_sock_should_retry(ret)) {
             ret = -2;
@@ -337,8 +331,8 @@ int BIO_accept(int sock, char **ip_port)
     }
 
     if (ip_port != NULL) {
-        char *host = BIO_ADDR_hostname_string(res, 1);
-        char *port = BIO_ADDR_service_string(res, 1);
+        char *host = BIO_ADDR_hostname_string(&res, 1);
+        char *port = BIO_ADDR_service_string(&res, 1);
         *ip_port = OPENSSL_zalloc(strlen(host) + strlen(port) + 2);
         strcpy(*ip_port, host);
         strcat(*ip_port, ":");
@@ -348,7 +342,6 @@ int BIO_accept(int sock, char **ip_port)
     }
 
  end:
-    BIO_ADDR_free(res);
     return ret;
 }
 # endif
diff --git a/crypto/bio/b_sock2.c b/crypto/bio/b_sock2.c
index 4bf5cf3..bf613ac 100644
--- a/crypto/bio/b_sock2.c
+++ b/crypto/bio/b_sock2.c
@@ -274,10 +274,12 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
  * @options: BIO socket options, applied on the accepted socket.
  *
  */
-int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options)
+int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
 {
     socklen_t len;
     int accepted_sock;
+    BIO_ADDR locaddr;
+    BIO_ADDR *addr = addr_ == NULL ? &locaddr : addr_;
 
     len = sizeof(*addr);
     accepted_sock = accept(accept_sock,


More information about the openssl-commits mailing list