[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Mar 30 16:46:16 UTC 2016


The branch master has been updated
       via  622c7e99a9e9c4632b483895cf2dc5edaa2e52bd (commit)
      from  3eefcea116b8143e99fbd9681ef8e364113c2d23 (commit)


- Log -----------------------------------------------------------------
commit 622c7e99a9e9c4632b483895cf2dc5edaa2e52bd
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Mar 30 18:18:24 2016 +0200

    Rearrange the use of 'proto' in BIO_lookup
    
    'proto' wasn't properly used as a fallback in all appropriate cases.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

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

Summary of changes:
 crypto/bio/b_addr.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c
index 0a6c5e9..663ec2e 100644
--- a/crypto/bio/b_addr.c
+++ b/crypto/bio/b_addr.c
@@ -742,7 +742,6 @@ int BIO_lookup(const char *host, const char *service,
 #else
         struct servent se_fallback = { NULL, NULL, 0, NULL };
 #endif
-        char *proto = NULL;
 
         CRYPTO_THREAD_run_once(&bio_lookup_init, do_bio_lookup_init);
 
@@ -778,11 +777,21 @@ int BIO_lookup(const char *host, const char *service,
 
         if (service == NULL) {
             se_fallback.s_port = 0;
-            se_fallback.s_proto = proto;
+            se_fallback.s_proto = NULL;
             se = &se_fallback;
         } else {
             char *endp = NULL;
             long portnum = strtol(service, &endp, 10);
+            char *proto = NULL;
+
+            switch (socktype) {
+            case SOCK_STREAM:
+                proto = "tcp";
+                break;
+            case SOCK_DGRAM:
+                proto = "udp";
+                break;
+            }
 
             if (endp != service && *endp == '\0'
                     && portnum > 0 && portnum < 65536) {
@@ -790,14 +799,6 @@ int BIO_lookup(const char *host, const char *service,
                 se_fallback.s_proto = proto;
                 se = &se_fallback;
             } else if (endp == service) {
-                switch (socktype) {
-                case SOCK_STREAM:
-                    proto = "tcp";
-                    break;
-                case SOCK_DGRAM:
-                    proto = "udp";
-                    break;
-                }
                 se = getservbyname(service, proto);
 
                 if (se == NULL) {


More information about the openssl-commits mailing list