crypto/bio/bss_conn.c:206: error: RESOURCE_LEAK
  resource acquired by call to `BIO_socket()` at line 137, column 19 is not released after line 206, column 18.
Showing all 40 steps of the trace


crypto/bio/bss_conn.c:75:1: start of procedure conn_state()
73.   };
74.   
75. > static int conn_state(BIO *b, BIO_CONNECT *c)
76.   {
77.       int ret = -1, i;

crypto/bio/bss_conn.c:77:5: 
75.   static int conn_state(BIO *b, BIO_CONNECT *c)
76.   {
77. >     int ret = -1, i;
78.       BIO_info_cb *cb = NULL;
79.   

crypto/bio/bss_conn.c:78:5: 
76.   {
77.       int ret = -1, i;
78. >     BIO_info_cb *cb = NULL;
79.   
80.       if (c->info_callback != NULL)

crypto/bio/bss_conn.c:80:9: Taking true branch
78.       BIO_info_cb *cb = NULL;
79.   
80.       if (c->info_callback != NULL)
              ^
81.           cb = c->info_callback;
82.   

crypto/bio/bss_conn.c:81:9: 
79.   
80.       if (c->info_callback != NULL)
81. >         cb = c->info_callback;
82.   
83.       for (;;) {

crypto/bio/bss_conn.c:209:5: Loop condition is true. Entering loop body
207.                   goto end;
208.           }
209.       }
           ^
210.   
211.       /* Loop does not exit */

crypto/bio/bss_conn.c:84:9: 
82.   
83.       for (;;) {
84. >         switch (c->state) {
85.           case BIO_CONN_S_BEFORE:
86.               if (c->param_hostname == NULL && c->param_service == NULL) {

crypto/bio/bss_conn.c:85:9: Switch condition is false. Skipping switch case
83.       for (;;) {
84.           switch (c->state) {
85.           case BIO_CONN_S_BEFORE:
              ^
86.               if (c->param_hostname == NULL && c->param_service == NULL) {
87.                   BIOerr(BIO_F_CONN_STATE, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED);

crypto/bio/bss_conn.c:96:9: Switch condition is false. Skipping switch case
94.               break;
95.   
96.           case BIO_CONN_S_GET_ADDR:
              ^
97.               {
98.                   int family = AF_UNSPEC;

crypto/bio/bss_conn.c:136:9: Switch condition is true. Entering switch case
134.               break;
135.   
136.           case BIO_CONN_S_CREATE_SOCKET:
               ^
137.               ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
138.                                BIO_ADDRINFO_socktype(c->addr_iter),

crypto/bio/bss_conn.c:137:13: 
135.   
136.           case BIO_CONN_S_CREATE_SOCKET:
137. >             ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
138.                                BIO_ADDRINFO_socktype(c->addr_iter),
139.                                BIO_ADDRINFO_protocol(c->addr_iter), 0);

crypto/bio/b_addr.c:349:1: start of procedure BIO_ADDRINFO_family()
  347.   }
  348.   
  349. > int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai)
  350.   {
  351.       if (bai != NULL)

crypto/bio/b_addr.c:351:9: Taking true branch
  349.   int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai)
  350.   {
  351.       if (bai != NULL)
                 ^
  352.           return bai->bai_family;
  353.       return 0;

crypto/bio/b_addr.c:352:9: 
  350.   {
  351.       if (bai != NULL)
  352. >         return bai->bai_family;
  353.       return 0;
  354.   }

crypto/bio/b_addr.c:354:1: return from a call to BIO_ADDRINFO_family
  352.           return bai->bai_family;
  353.       return 0;
  354. > }
  355.   
  356.   int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai)

crypto/bio/b_addr.c:356:1: start of procedure BIO_ADDRINFO_socktype()
  354.   }
  355.   
  356. > int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai)
  357.   {
  358.       if (bai != NULL)

crypto/bio/b_addr.c:358:9: Taking true branch
  356.   int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai)
  357.   {
  358.       if (bai != NULL)
                 ^
  359.           return bai->bai_socktype;
  360.       return 0;

crypto/bio/b_addr.c:359:9: 
  357.   {
  358.       if (bai != NULL)
  359. >         return bai->bai_socktype;
  360.       return 0;
  361.   }

crypto/bio/b_addr.c:361:1: return from a call to BIO_ADDRINFO_socktype
  359.           return bai->bai_socktype;
  360.       return 0;
  361. > }
  362.   
  363.   int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai)

crypto/bio/b_addr.c:363:1: start of procedure BIO_ADDRINFO_protocol()
  361.   }
  362.   
  363. > int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai)
  364.   {
  365.       if (bai != NULL) {

crypto/bio/b_addr.c:365:9: Taking true branch
  363.   int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai)
  364.   {
  365.       if (bai != NULL) {
                 ^
  366.           if (bai->bai_protocol != 0)
  367.               return bai->bai_protocol;

crypto/bio/b_addr.c:366:13: Taking true branch
  364.   {
  365.       if (bai != NULL) {
  366.           if (bai->bai_protocol != 0)
                     ^
  367.               return bai->bai_protocol;
  368.   

crypto/bio/b_addr.c:367:13: 
  365.       if (bai != NULL) {
  366.           if (bai->bai_protocol != 0)
  367. >             return bai->bai_protocol;
  368.   
  369.   #ifdef AF_UNIX

crypto/bio/b_addr.c:384:1: return from a call to BIO_ADDRINFO_protocol
  382.       }
  383.       return 0;
  384. > }
  385.   
  386.   /*

crypto/bio/b_sock2.c:40:1: start of procedure BIO_socket()
  38.    * failure errno is set, and a status is added to the OpenSSL error stack.
  39.    */
  40. > int BIO_socket(int domain, int socktype, int protocol, int options)
  41.   {
  42.       int sock = -1;

crypto/bio/b_sock2.c:42:5: 
  40.   int BIO_socket(int domain, int socktype, int protocol, int options)
  41.   {
  42. >     int sock = -1;
  43.   
  44.       if (BIO_sock_init() != 1)

crypto/bio/b_sock2.c:44:9: 
  42.       int sock = -1;
  43.   
  44. >     if (BIO_sock_init() != 1)
  45.           return INVALID_SOCKET;
  46.   

crypto/bio/b_sock.c:117:1: start of procedure BIO_sock_init()
    115.   # endif
    116.   
    117. > int BIO_sock_init(void)
    118.   {
    119.   # ifdef OPENSSL_SYS_WINDOWS

crypto/bio/b_sock.c:146:5: 
    144.   # endif
    145.   
    146. >     return 1;
    147.   }
    148.   

crypto/bio/b_sock.c:147:1: return from a call to BIO_sock_init
    145.   
    146.       return 1;
    147. > }
    148.   
    149.   void bio_sock_cleanup_int(void)

crypto/bio/b_sock2.c:44:9: Taking false branch
  42.       int sock = -1;
  43.   
  44.       if (BIO_sock_init() != 1)
                ^
  45.           return INVALID_SOCKET;
  46.   

crypto/bio/b_sock2.c:47:5: 
  45.           return INVALID_SOCKET;
  46.   
  47. >     sock = socket(domain, socktype, protocol);
  48.       if (sock == -1) {
  49.           ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),

crypto/bio/b_sock2.c:48:9: Taking false branch
  46.   
  47.       sock = socket(domain, socktype, protocol);
  48.       if (sock == -1) {
                ^
  49.           ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
  50.                          "calling socket()");

crypto/bio/b_sock2.c:55:5: 
  53.       }
  54.   
  55. >     return sock;
  56.   }
  57.   

crypto/bio/b_sock2.c:56:1: return from a call to BIO_socket
  54.   
  55.       return sock;
  56. > }
  57.   
  58.   /*-

crypto/bio/bss_conn.c:140:17: Taking false branch
138.                                BIO_ADDRINFO_socktype(c->addr_iter),
139.                                BIO_ADDRINFO_protocol(c->addr_iter), 0);
140.               if (ret == (int)INVALID_SOCKET) {
                       ^
141.                   ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
142.                                  "calling socket(%s, %s)",

crypto/bio/bss_conn.c:147:13: 
145.                   goto exit_loop;
146.               }
147. >             b->num = ret;
148.               c->state = BIO_CONN_S_CONNECT;
149.               break;

crypto/bio/bss_conn.c:148:13: 
146.               }
147.               b->num = ret;
148. >             c->state = BIO_CONN_S_CONNECT;
149.               break;
150.   

crypto/bio/bss_conn.c:205:13: Taking true branch
203.           }
204.   
205.           if (cb != NULL) {
                   ^
206.               if ((ret = cb((BIO *)b, c->state, ret)) == 0)
207.                   goto end;

crypto/bio/bss_conn.c:206:17: Skipping __function_pointer__(): unresolved function pointer
204.   
205.           if (cb != NULL) {
206.               if ((ret = cb((BIO *)b, c->state, ret)) == 0)
                       ^
207.                   goto end;
208.           }

static int conn_state(BIO *b, BIO_CONNECT *c)
{
    int ret = -1, i;
    BIO_info_cb *cb = NULL;
    if (c->info_callback != NULL)
        cb = c->info_callback;
    for (;;) {
        switch (c->state) {
        case BIO_CONN_S_BEFORE:
            if (c->param_hostname == NULL && c->param_service == NULL) {
                BIOerr(BIO_F_CONN_STATE, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED);
                ERR_add_error_data(4,
                                   "hostname=", c->param_hostname,
                                   " service=", c->param_service);
                goto exit_loop;
            }
            c->state = BIO_CONN_S_GET_ADDR;
            break;
        case BIO_CONN_S_GET_ADDR:
            {
                int family = AF_UNSPEC;
                switch (c->connect_family) {
                case BIO_FAMILY_IPV6:
                    if (1) {
#ifdef AF_INET6
                        family = AF_INET6;
                    } else {
#endif
                        BIOerr(BIO_F_CONN_STATE, BIO_R_UNAVAILABLE_IP_FAMILY);
                        goto exit_loop;
                    }
                    break;
                case BIO_FAMILY_IPV4:
                    family = AF_INET;
                    break;
                case BIO_FAMILY_IPANY:
                    family = AF_UNSPEC;
                    break;
                default:
                    BIOerr(BIO_F_CONN_STATE, BIO_R_UNSUPPORTED_IP_FAMILY);
                    goto exit_loop;
                }
                if (BIO_lookup(c->param_hostname, c->param_service,
                               BIO_LOOKUP_CLIENT,
                               family, SOCK_STREAM, &c->addr_first) == 0)
                    goto exit_loop;
            }
            if (c->addr_first == NULL) {
                BIOerr(BIO_F_CONN_STATE, BIO_R_LOOKUP_RETURNED_NOTHING);
                goto exit_loop;
            }
            c->addr_iter = c->addr_first;
            c->state = BIO_CONN_S_CREATE_SOCKET;
            break;
        case BIO_CONN_S_CREATE_SOCKET:
            ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
                             BIO_ADDRINFO_socktype(c->addr_iter),
                             BIO_ADDRINFO_protocol(c->addr_iter), 0);
            if (ret == (int)INVALID_SOCKET) {
                ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
                               "calling socket(%s, %s)",
                               c->param_hostname, c->param_service);
                BIOerr(BIO_F_CONN_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
                goto exit_loop;
            }
            b->num = ret;
            c->state = BIO_CONN_S_CONNECT;
            break;
        case BIO_CONN_S_CONNECT:
            BIO_clear_retry_flags(b);
            ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter),
                              BIO_SOCK_KEEPALIVE | c->connect_mode);
            b->retry_reason = 0;
            if (ret == 0) {
                if (BIO_sock_should_retry(ret)) {
                    BIO_set_retry_special(b);
                    c->state = BIO_CONN_S_BLOCKED_CONNECT;
                    b->retry_reason = BIO_RR_CONNECT;
                    ERR_clear_error();
                } else if ((c->addr_iter = BIO_ADDRINFO_next(c->addr_iter))
                           != NULL) {
                    BIO_closesocket(b->num);
                    c->state = BIO_CONN_S_CREATE_SOCKET;
                    ERR_clear_error();
                    break;
                } else {
                    ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
                                   "calling connect(%s, %s)",
                                    c->param_hostname, c->param_service);
                    BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);
                }
                goto exit_loop;
            } else {
                c->state = BIO_CONN_S_OK;
            }
            break;
        case BIO_CONN_S_BLOCKED_CONNECT:
            i = BIO_sock_error(b->num);
            if (i) {
                BIO_clear_retry_flags(b);
                ERR_raise_data(ERR_LIB_SYS, i,
                               "calling connect(%s, %s)",
                                c->param_hostname, c->param_service);
                BIOerr(BIO_F_CONN_STATE, BIO_R_NBIO_CONNECT_ERROR);
                ret = 0;
                goto exit_loop;
            } else
                c->state = BIO_CONN_S_OK;
            break;
        case BIO_CONN_S_OK:
            ret = 1;
            goto exit_loop;
        default:
            goto exit_loop;
        }
        if (cb != NULL) {
            if ((ret = cb((BIO *)b, c->state, ret)) == 0)
                goto end;
        }
    }
 exit_loop:
    if (cb != NULL)
        ret = cb((BIO *)b, c->state, ret);
 end:
    return ret;
}
['static int conn_state(BIO *b, BIO_CONNECT *c)\n{\n    int ret = -1, i;\n    BIO_info_cb *cb = NULL;\n    if (c->info_callback != NULL)\n        cb = c->info_callback;\n    for (;;) {\n        switch (c->state) {\n        case BIO_CONN_S_BEFORE:\n            if (c->param_hostname == NULL && c->param_service == NULL) {\n                BIOerr(BIO_F_CONN_STATE, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED);\n                ERR_add_error_data(4,\n                                   "hostname=", c->param_hostname,\n                                   " service=", c->param_service);\n                goto exit_loop;\n            }\n            c->state = BIO_CONN_S_GET_ADDR;\n            break;\n        case BIO_CONN_S_GET_ADDR:\n            {\n                int family = AF_UNSPEC;\n                switch (c->connect_family) {\n                case BIO_FAMILY_IPV6:\n                    if (1) {\n#ifdef AF_INET6\n                        family = AF_INET6;\n                    } else {\n#endif\n                        BIOerr(BIO_F_CONN_STATE, BIO_R_UNAVAILABLE_IP_FAMILY);\n                        goto exit_loop;\n                    }\n                    break;\n                case BIO_FAMILY_IPV4:\n                    family = AF_INET;\n                    break;\n                case BIO_FAMILY_IPANY:\n                    family = AF_UNSPEC;\n                    break;\n                default:\n                    BIOerr(BIO_F_CONN_STATE, BIO_R_UNSUPPORTED_IP_FAMILY);\n                    goto exit_loop;\n                }\n                if (BIO_lookup(c->param_hostname, c->param_service,\n                               BIO_LOOKUP_CLIENT,\n                               family, SOCK_STREAM, &c->addr_first) == 0)\n                    goto exit_loop;\n            }\n            if (c->addr_first == NULL) {\n                BIOerr(BIO_F_CONN_STATE, BIO_R_LOOKUP_RETURNED_NOTHING);\n                goto exit_loop;\n            }\n            c->addr_iter = c->addr_first;\n            c->state = BIO_CONN_S_CREATE_SOCKET;\n            break;\n        case BIO_CONN_S_CREATE_SOCKET:\n            ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),\n                             BIO_ADDRINFO_socktype(c->addr_iter),\n                             BIO_ADDRINFO_protocol(c->addr_iter), 0);\n            if (ret == (int)INVALID_SOCKET) {\n                ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),\n                               "calling socket(%s, %s)",\n                               c->param_hostname, c->param_service);\n                BIOerr(BIO_F_CONN_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);\n                goto exit_loop;\n            }\n            b->num = ret;\n            c->state = BIO_CONN_S_CONNECT;\n            break;\n        case BIO_CONN_S_CONNECT:\n            BIO_clear_retry_flags(b);\n            ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter),\n                              BIO_SOCK_KEEPALIVE | c->connect_mode);\n            b->retry_reason = 0;\n            if (ret == 0) {\n                if (BIO_sock_should_retry(ret)) {\n                    BIO_set_retry_special(b);\n                    c->state = BIO_CONN_S_BLOCKED_CONNECT;\n                    b->retry_reason = BIO_RR_CONNECT;\n                    ERR_clear_error();\n                } else if ((c->addr_iter = BIO_ADDRINFO_next(c->addr_iter))\n                           != NULL) {\n                    BIO_closesocket(b->num);\n                    c->state = BIO_CONN_S_CREATE_SOCKET;\n                    ERR_clear_error();\n                    break;\n                } else {\n                    ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),\n                                   "calling connect(%s, %s)",\n                                    c->param_hostname, c->param_service);\n                    BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);\n                }\n                goto exit_loop;\n            } else {\n                c->state = BIO_CONN_S_OK;\n            }\n            break;\n        case BIO_CONN_S_BLOCKED_CONNECT:\n            i = BIO_sock_error(b->num);\n            if (i) {\n                BIO_clear_retry_flags(b);\n                ERR_raise_data(ERR_LIB_SYS, i,\n                               "calling connect(%s, %s)",\n                                c->param_hostname, c->param_service);\n                BIOerr(BIO_F_CONN_STATE, BIO_R_NBIO_CONNECT_ERROR);\n                ret = 0;\n                goto exit_loop;\n            } else\n                c->state = BIO_CONN_S_OK;\n            break;\n        case BIO_CONN_S_OK:\n            ret = 1;\n            goto exit_loop;\n        default:\n            goto exit_loop;\n        }\n        if (cb != NULL) {\n            if ((ret = cb((BIO *)b, c->state, ret)) == 0)\n                goto end;\n        }\n    }\n exit_loop:\n    if (cb != NULL)\n        ret = cb((BIO *)b, c->state, ret);\n end:\n    return ret;\n}', 'int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai)\n{\n    if (bai != NULL)\n        return bai->bai_family;\n    return 0;\n}', 'int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai)\n{\n    if (bai != NULL)\n        return bai->bai_socktype;\n    return 0;\n}', 'int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai)\n{\n    if (bai != NULL) {\n        if (bai->bai_protocol != 0)\n            return bai->bai_protocol;\n#ifdef AF_UNIX\n        if (bai->bai_family == AF_UNIX)\n            return 0;\n#endif\n        switch (bai->bai_socktype) {\n        case SOCK_STREAM:\n            return IPPROTO_TCP;\n        case SOCK_DGRAM:\n            return IPPROTO_UDP;\n        default:\n            break;\n        }\n    }\n    return 0;\n}', 'int BIO_socket(int domain, int socktype, int protocol, int options)\n{\n    int sock = -1;\n    if (BIO_sock_init() != 1)\n        return INVALID_SOCKET;\n    sock = socket(domain, socktype, protocol);\n    if (sock == -1) {\n        ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),\n                       "calling socket()");\n        BIOerr(BIO_F_BIO_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);\n        return INVALID_SOCKET;\n    }\n    return sock;\n}', 'int BIO_sock_init(void)\n{\n# ifdef OPENSSL_SYS_WINDOWS\n    static struct WSAData wsa_state;\n    if (!wsa_init_done) {\n        wsa_init_done = 1;\n        memset(&wsa_state, 0, sizeof(wsa_state));\n        if (WSAStartup(0x0202, &wsa_state) != 0) {\n            ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),\n                           "calling wsastartup()");\n            BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP);\n            return -1;\n        }\n    }\n# endif\n# ifdef WATT32\n    extern int _watt_do_exit;\n    _watt_do_exit = 0;\n    if (sock_init())\n        return -1;\n# endif\n    return 1;\n}']