[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Thu Apr 28 12:04:10 UTC 2016


The branch master has been updated
       via  2bd8c8539595b8708e825d306a45ddddc17c915c (commit)
      from  d78df5dfd650e6de159a19a033513481064644f5 (commit)


- Log -----------------------------------------------------------------
commit 2bd8c8539595b8708e825d306a45ddddc17c915c
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Apr 28 13:19:38 2016 +0200

    Make BIO_sock_error return a proper error code when getsockopt fails
    
    BIO_sock_error() returned 1 when getsockopt() fails when it should
    return the error code for that failure.
    
    Additionally, the optlen parameter to getsockopt() has to point at
    the size of the area that the optval parameter points at rather than
    zero.  Some systems may forgive it being zero, but others don't.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>

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

Summary of changes:
 crypto/bio/b_sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index a2d0100..071acda 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -141,7 +141,7 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
 int BIO_sock_error(int sock)
 {
     int j = 0, i;
-    socklen_t size = 0;
+    socklen_t size = sizeof(j);
 
     /*
      * Note: under Windows the third parameter is of type (char *) whereas
@@ -151,7 +151,7 @@ int BIO_sock_error(int sock)
      */
     i = getsockopt(sock, SOL_SOCKET, SO_ERROR, (void *)&j, &size);
     if (i < 0)
-        return (1);
+        return (get_last_socket_error());
     else
         return (j);
 }


More information about the openssl-commits mailing list