crypto/bio/bss_conn.c:209: error: RESOURCE_LEAK
  resource acquired by call to `BIO_socket()` at line 137, column 19 is not released after line 209, 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:212:5: Loop condition is true. Entering loop body
210.                   goto end;
211.           }
212.       }
           ^
213.   
214.       /* 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:348:1: start of procedure BIO_ADDRINFO_family()
  346.   }
  347.   
  348. > int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai)
  349.   {
  350.       if (bai != NULL)

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

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

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

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

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

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

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

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

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

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

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

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

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:145:5: 
    143.   # endif
    144.   
    145. >     return 1;
    146.   }
    147.   

crypto/bio/b_sock.c:146:1: return from a call to BIO_sock_init
    144.   
    145.       return 1;
    146. > }
    147.   
    148.   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.           FUNCerr("socket", 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.           FUNCerr("socket", get_last_socket_error());
  50.           BIOerr(BIO_F_BIO_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);

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

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

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.                   FUNCerr("socket", get_last_socket_error());
142.                   ERR_add_error_data(4,

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

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

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

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

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) {
                FUNCerr("socket", get_last_socket_error());
                ERR_add_error_data(4,
                                   "hostname=", c->param_hostname,
                                   " service=", 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 {
                    FUNCerr("connect", get_last_socket_error());
                    ERR_add_error_data(4,
                                       "hostname=", c->param_hostname,
                                       " service=", 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);
                FUNCerr("connect", i);
                ERR_add_error_data(4,
                                   "hostname=", c->param_hostname,
                                   " service=", 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                FUNCerr("socket", get_last_socket_error());\n                ERR_add_error_data(4,\n                                   "hostname=", c->param_hostname,\n                                   " service=", 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                    FUNCerr("connect", get_last_socket_error());\n                    ERR_add_error_data(4,\n                                       "hostname=", c->param_hostname,\n                                       " service=", 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                FUNCerr("connect", i);\n                ERR_add_error_data(4,\n                                   "hostname=", c->param_hostname,\n                                   " service=", 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        FUNCerr("socket", get_last_socket_error());\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            FUNCerr("wsastartup", get_last_socket_error());\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}']