apps/s_server.c:2199: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `SSL_clear`.
Showing all 14 steps of the trace


apps/s_server.c:2177:15: Call
2175.   
2176.       if (con == NULL) {
2177.           con = SSL_new(ctx);
                      ^
2178.   #ifndef OPENSSL_NO_TLSEXT
2179.           if (s_tlsextdebug) {

ssl/ssl_lib.c:283:1: Parameter `ctx->sessions->num_items`
  281.   }
  282.   
  283. > SSL *SSL_new(SSL_CTX *ctx)
  284.   {
  285.       SSL *s;

apps/s_server.c:2199:5: Call
2197.               SSL_set_session_id_context(con, context, strlen((char *)context));
2198.       }
2199.       SSL_clear(con);
            ^
2200.   #if 0
2201.   # ifdef TLSEXT_TYPE_opaque_prf_input

ssl/ssl_lib.c:190:1: Parameter `s->ctx->sessions->num_items`
  188.   };
  189.   
  190. > int SSL_clear(SSL *s)
  191.   {
  192.   

ssl/ssl_lib.c:198:9: Call
  196.       }
  197.   
  198.       if (ssl_clear_bad_session(s)) {
                 ^
  199.           SSL_SESSION_free(s->session);
  200.           s->session = NULL;

ssl/ssl_sess.c:990:1: Parameter `s->ctx->sessions->num_items`
    988.   }
    989.   
    990. > int ssl_clear_bad_session(SSL *s)
    991.   {
    992.       if ((s->session != NULL) &&

ssl/ssl_sess.c:995:9: Call
    993.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
    994.           !(SSL_in_init(s) || SSL_in_before(s))) {
    995.           SSL_CTX_remove_session(s->ctx, s->session);
                   ^
    996.           return (1);
    997.       } else

ssl/ssl_sess.c:673:1: Parameter `ctx->sessions->num_items`
      671.   }
      672.   
      673. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      674.   {
      675.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:675:12: Call
      673.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      674.   {
      675.       return remove_session_lock(ctx, c, 1);
                        ^
      676.   }
      677.   

ssl/ssl_sess.c:678:1: Parameter `ctx->sessions->num_items`
        676.   }
        677.   
        678. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        679.   {
        680.       SSL_SESSION *r;

ssl/ssl_sess.c:688:17: Call
        686.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
        687.               ret = 1;
        688.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                               ^
        689.               SSL_SESSION_list_remove(ctx, c);
        690.           }

crypto/lhash/lhash.c:213:1: <LHS trace>
211.   }
212.   
213. > void *lh_delete(_LHASH *lh, const void *data)
214.   {
215.       unsigned long hash;

crypto/lhash/lhash.c:213:1: Parameter `lh->num_items`
          211.   }
          212.   
          213. > void *lh_delete(_LHASH *lh, const void *data)
          214.   {
          215.       unsigned long hash;

crypto/lhash/lhash.c:233:5: Binary operation: ([0, +oo] - 1):unsigned64 by call to `SSL_clear` 
          231.       }
          232.   
          233.       lh->num_items--;
                     ^
          234.       if ((lh->num_nodes > MIN_NODES) &&
          235.           (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))

void *lh_delete(_LHASH *lh, const void *data)
{
    unsigned long hash;
    LHASH_NODE *nn, **rn;
    void *ret;
    lh->error = 0;
    rn = getrn(lh, data, &hash);
    if (*rn == NULL) {
        lh->num_no_delete++;
        return (NULL);
    } else {
        nn = *rn;
        *rn = nn->next;
        ret = nn->data;
        OPENSSL_free(nn);
        lh->num_delete++;
    }
    lh->num_items--;
    if ((lh->num_nodes > MIN_NODES) &&
        (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))
        contract(lh);
    return (ret);
}
['static int sv_body(char *hostname, int s, int stype, unsigned char *context)\n{\n    char *buf = NULL;\n    fd_set readfds;\n    int ret = 1, width;\n    int k, i;\n    unsigned long l;\n    SSL *con = NULL;\n    BIO *sbio;\n#ifndef OPENSSL_NO_KRB5\n    KSSL_CTX *kctx;\n#endif\n    struct timeval timeout;\n#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE)\n    struct timeval tv;\n#else\n    struct timeval *timeoutp;\n#endif\n    if ((buf = OPENSSL_malloc(bufsize)) == NULL) {\n        BIO_printf(bio_err, "out of memory\\n");\n        goto err;\n    }\n#ifdef FIONBIO\n    if (s_nbio) {\n        unsigned long sl = 1;\n        if (!s_quiet)\n            BIO_printf(bio_err, "turning on non blocking io\\n");\n        if (BIO_socket_ioctl(s, FIONBIO, &sl) < 0)\n            ERR_print_errors(bio_err);\n    }\n#endif\n    if (con == NULL) {\n        con = SSL_new(ctx);\n#ifndef OPENSSL_NO_TLSEXT\n        if (s_tlsextdebug) {\n            SSL_set_tlsext_debug_callback(con, tlsext_cb);\n            SSL_set_tlsext_debug_arg(con, bio_s_out);\n        }\n        if (s_tlsextstatus) {\n            SSL_CTX_set_tlsext_status_cb(ctx, cert_status_cb);\n            tlscstatp.err = bio_err;\n            SSL_CTX_set_tlsext_status_arg(ctx, &tlscstatp);\n        }\n#endif\n#ifndef OPENSSL_NO_KRB5\n        if ((kctx = kssl_ctx_new()) != NULL) {\n            SSL_set0_kssl_ctx(con, kctx);\n            kssl_ctx_setstring(kctx, KSSL_SERVICE, KRB5SVC);\n            kssl_ctx_setstring(kctx, KSSL_KEYTAB, KRB5KEYTAB);\n        }\n#endif\n        if (context)\n            SSL_set_session_id_context(con, context, strlen((char *)context));\n    }\n    SSL_clear(con);\n#if 0\n# ifdef TLSEXT_TYPE_opaque_prf_input\n    SSL_set_tlsext_opaque_prf_input(con, "Test server", 11);\n# endif\n#endif\n    if (stype == SOCK_DGRAM) {\n        sbio = BIO_new_dgram(s, BIO_NOCLOSE);\n        if (enable_timeouts) {\n            timeout.tv_sec = 0;\n            timeout.tv_usec = DGRAM_RCV_TIMEOUT;\n            BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout);\n            timeout.tv_sec = 0;\n            timeout.tv_usec = DGRAM_SND_TIMEOUT;\n            BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);\n        }\n        if (socket_mtu) {\n            if (socket_mtu < DTLS_get_link_min_mtu(con)) {\n                BIO_printf(bio_err, "MTU too small. Must be at least %ld\\n",\n                           DTLS_get_link_min_mtu(con));\n                ret = -1;\n                BIO_free(sbio);\n                goto err;\n            }\n            SSL_set_options(con, SSL_OP_NO_QUERY_MTU);\n            if (!DTLS_set_link_mtu(con, socket_mtu)) {\n                BIO_printf(bio_err, "Failed to set MTU\\n");\n                ret = -1;\n                BIO_free(sbio);\n                goto err;\n            }\n        } else\n            BIO_ctrl(sbio, BIO_CTRL_DGRAM_MTU_DISCOVER, 0, NULL);\n        SSL_set_options(con, SSL_OP_COOKIE_EXCHANGE);\n    } else\n        sbio = BIO_new_socket(s, BIO_NOCLOSE);\n    if (s_nbio_test) {\n        BIO *test;\n        test = BIO_new(BIO_f_nbio_test());\n        sbio = BIO_push(test, sbio);\n    }\n#ifndef OPENSSL_NO_JPAKE\n    if (jpake_secret)\n        jpake_server_auth(bio_s_out, sbio, jpake_secret);\n#endif\n    SSL_set_bio(con, sbio, sbio);\n    SSL_set_accept_state(con);\n    if (s_debug) {\n        SSL_set_debug(con, 1);\n        BIO_set_callback(SSL_get_rbio(con), bio_dump_callback);\n        BIO_set_callback_arg(SSL_get_rbio(con), (char *)bio_s_out);\n    }\n    if (s_msg) {\n#ifndef OPENSSL_NO_SSL_TRACE\n        if (s_msg == 2)\n            SSL_set_msg_callback(con, SSL_trace);\n        else\n#endif\n            SSL_set_msg_callback(con, msg_cb);\n        SSL_set_msg_callback_arg(con, bio_s_msg ? bio_s_msg : bio_s_out);\n    }\n#ifndef OPENSSL_NO_TLSEXT\n    if (s_tlsextdebug) {\n        SSL_set_tlsext_debug_callback(con, tlsext_cb);\n        SSL_set_tlsext_debug_arg(con, bio_s_out);\n    }\n#endif\n    width = s + 1;\n    for (;;) {\n        int read_from_terminal;\n        int read_from_sslcon;\n        read_from_terminal = 0;\n        read_from_sslcon = SSL_pending(con);\n        if (!read_from_sslcon) {\n            FD_ZERO(&readfds);\n#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE)\n            openssl_fdset(fileno(stdin), &readfds);\n#endif\n            openssl_fdset(s, &readfds);\n#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE)\n            tv.tv_sec = 1;\n            tv.tv_usec = 0;\n            i = select(width, (void *)&readfds, NULL, NULL, &tv);\n            if ((i < 0) || (!i && !_kbhit()))\n                continue;\n            if (_kbhit())\n                read_from_terminal = 1;\n#else\n            if ((SSL_version(con) == DTLS1_VERSION) &&\n                DTLSv1_get_timeout(con, &timeout))\n                timeoutp = &timeout;\n            else\n                timeoutp = NULL;\n            i = select(width, (void *)&readfds, NULL, NULL, timeoutp);\n            if ((SSL_version(con) == DTLS1_VERSION)\n                && DTLSv1_handle_timeout(con) > 0) {\n                BIO_printf(bio_err, "TIMEOUT occurred\\n");\n            }\n            if (i <= 0)\n                continue;\n            if (FD_ISSET(fileno(stdin), &readfds))\n                read_from_terminal = 1;\n#endif\n            if (FD_ISSET(s, &readfds))\n                read_from_sslcon = 1;\n        }\n        if (read_from_terminal) {\n            if (s_crlf) {\n                int j, lf_num;\n                i = raw_read_stdin(buf, bufsize / 2);\n                lf_num = 0;\n                for (j = 0; j < i; j++)\n                    if (buf[j] == \'\\n\')\n                        lf_num++;\n                for (j = i - 1; j >= 0; j--) {\n                    buf[j + lf_num] = buf[j];\n                    if (buf[j] == \'\\n\') {\n                        lf_num--;\n                        i++;\n                        buf[j + lf_num] = \'\\r\';\n                    }\n                }\n                assert(lf_num == 0);\n            } else\n                i = raw_read_stdin(buf, bufsize);\n            if (!s_quiet && !s_brief) {\n                if ((i <= 0) || (buf[0] == \'Q\')) {\n                    BIO_printf(bio_s_out, "DONE\\n");\n                    SHUTDOWN(s);\n                    close_accept_socket();\n                    ret = -11;\n                    goto err;\n                }\n                if ((i <= 0) || (buf[0] == \'q\')) {\n                    BIO_printf(bio_s_out, "DONE\\n");\n                    if (SSL_version(con) != DTLS1_VERSION)\n                        SHUTDOWN(s);\n                    goto err;\n                }\n#ifndef OPENSSL_NO_HEARTBEATS\n                if ((buf[0] == \'B\') && ((buf[1] == \'\\n\') || (buf[1] == \'\\r\'))) {\n                    BIO_printf(bio_err, "HEARTBEATING\\n");\n                    SSL_heartbeat(con);\n                    i = 0;\n                    continue;\n                }\n#endif\n                if ((buf[0] == \'r\') && ((buf[1] == \'\\n\') || (buf[1] == \'\\r\'))) {\n                    SSL_renegotiate(con);\n                    i = SSL_do_handshake(con);\n                    printf("SSL_do_handshake -> %d\\n", i);\n                    i = 0;\n                    continue;\n                }\n                if ((buf[0] == \'R\') && ((buf[1] == \'\\n\') || (buf[1] == \'\\r\'))) {\n                    SSL_set_verify(con,\n                                   SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE,\n                                   NULL);\n                    SSL_renegotiate(con);\n                    i = SSL_do_handshake(con);\n                    printf("SSL_do_handshake -> %d\\n", i);\n                    i = 0;\n                    continue;\n                }\n                if (buf[0] == \'P\') {\n                    static const char *str = "Lets print some clear text\\n";\n                    BIO_write(SSL_get_wbio(con), str, strlen(str));\n                }\n                if (buf[0] == \'S\') {\n                    print_stats(bio_s_out, SSL_get_SSL_CTX(con));\n                }\n            }\n#ifdef CHARSET_EBCDIC\n            ebcdic2ascii(buf, buf, i);\n#endif\n            l = k = 0;\n            for (;;) {\n#ifdef RENEG\n                {\n                    static count = 0;\n                    if (++count == 100) {\n                        count = 0;\n                        SSL_renegotiate(con);\n                    }\n                }\n#endif\n                k = SSL_write(con, &(buf[l]), (unsigned int)i);\n#ifndef OPENSSL_NO_SRP\n                while (SSL_get_error(con, k) == SSL_ERROR_WANT_X509_LOOKUP) {\n                    BIO_printf(bio_s_out, "LOOKUP renego during write\\n");\n                    srp_callback_parm.user =\n                        SRP_VBASE_get_by_user(srp_callback_parm.vb,\n                                              srp_callback_parm.login);\n                    if (srp_callback_parm.user)\n                        BIO_printf(bio_s_out, "LOOKUP done %s\\n",\n                                   srp_callback_parm.user->info);\n                    else\n                        BIO_printf(bio_s_out, "LOOKUP not successful\\n");\n                    k = SSL_write(con, &(buf[l]), (unsigned int)i);\n                }\n#endif\n                switch (SSL_get_error(con, k)) {\n                case SSL_ERROR_NONE:\n                    break;\n                case SSL_ERROR_WANT_WRITE:\n                case SSL_ERROR_WANT_READ:\n                case SSL_ERROR_WANT_X509_LOOKUP:\n                    BIO_printf(bio_s_out, "Write BLOCK\\n");\n                    break;\n                case SSL_ERROR_SYSCALL:\n                case SSL_ERROR_SSL:\n                    BIO_printf(bio_s_out, "ERROR\\n");\n                    ERR_print_errors(bio_err);\n                    ret = 1;\n                    goto err;\n                case SSL_ERROR_ZERO_RETURN:\n                    BIO_printf(bio_s_out, "DONE\\n");\n                    ret = 1;\n                    goto err;\n                }\n                l += k;\n                i -= k;\n                if (i <= 0)\n                    break;\n            }\n        }\n        if (read_from_sslcon) {\n            if (!SSL_is_init_finished(con)) {\n                i = init_ssl_connection(con);\n                if (i < 0) {\n                    ret = 0;\n                    goto err;\n                } else if (i == 0) {\n                    ret = 1;\n                    goto err;\n                }\n            } else {\n again:\n                i = SSL_read(con, (char *)buf, bufsize);\n#ifndef OPENSSL_NO_SRP\n                while (SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP) {\n                    BIO_printf(bio_s_out, "LOOKUP renego during read\\n");\n                    srp_callback_parm.user =\n                        SRP_VBASE_get_by_user(srp_callback_parm.vb,\n                                              srp_callback_parm.login);\n                    if (srp_callback_parm.user)\n                        BIO_printf(bio_s_out, "LOOKUP done %s\\n",\n                                   srp_callback_parm.user->info);\n                    else\n                        BIO_printf(bio_s_out, "LOOKUP not successful\\n");\n                    i = SSL_read(con, (char *)buf, bufsize);\n                }\n#endif\n                switch (SSL_get_error(con, i)) {\n                case SSL_ERROR_NONE:\n#ifdef CHARSET_EBCDIC\n                    ascii2ebcdic(buf, buf, i);\n#endif\n                    raw_write_stdout(buf, (unsigned int)i);\n                    if (SSL_pending(con))\n                        goto again;\n                    break;\n                case SSL_ERROR_WANT_WRITE:\n                case SSL_ERROR_WANT_READ:\n                    BIO_printf(bio_s_out, "Read BLOCK\\n");\n                    break;\n                case SSL_ERROR_SYSCALL:\n                case SSL_ERROR_SSL:\n                    BIO_printf(bio_s_out, "ERROR\\n");\n                    ERR_print_errors(bio_err);\n                    ret = 1;\n                    goto err;\n                case SSL_ERROR_ZERO_RETURN:\n                    BIO_printf(bio_s_out, "DONE\\n");\n                    ret = 1;\n                    goto err;\n                }\n            }\n        }\n    }\n err:\n    if (con != NULL) {\n        BIO_printf(bio_s_out, "shutting down SSL\\n");\n#if 1\n        SSL_set_shutdown(con, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);\n#else\n        SSL_shutdown(con);\n#endif\n        SSL_free(con);\n    }\n    BIO_printf(bio_s_out, "CONNECTION CLOSED\\n");\n    if (buf != NULL) {\n        OPENSSL_cleanse(buf, bufsize);\n        OPENSSL_free(buf);\n    }\n    if (ret >= 0)\n        BIO_printf(bio_s_out, "ACCEPT\\n");\n    return (ret);\n}', 'SSL *SSL_new(SSL_CTX *ctx)\n{\n    SSL *s;\n    if (ctx == NULL) {\n        SSLerr(SSL_F_SSL_NEW, SSL_R_NULL_SSL_CTX);\n        return (NULL);\n    }\n    if (ctx->method == NULL) {\n        SSLerr(SSL_F_SSL_NEW, SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION);\n        return (NULL);\n    }\n    s = (SSL *)OPENSSL_malloc(sizeof(SSL));\n    if (s == NULL)\n        goto err;\n    memset(s, 0, sizeof(SSL));\n#ifndef OPENSSL_NO_KRB5\n    s->kssl_ctx = kssl_ctx_new();\n#endif\n    s->options = ctx->options;\n    s->mode = ctx->mode;\n    s->max_cert_list = ctx->max_cert_list;\n    if (ctx->cert != NULL) {\n        s->cert = ssl_cert_dup(ctx->cert);\n        if (s->cert == NULL)\n            goto err;\n    } else\n        s->cert = NULL;\n    s->read_ahead = ctx->read_ahead;\n    s->msg_callback = ctx->msg_callback;\n    s->msg_callback_arg = ctx->msg_callback_arg;\n    s->verify_mode = ctx->verify_mode;\n    s->not_resumable_session_cb = ctx->not_resumable_session_cb;\n#if 0\n    s->verify_depth = ctx->verify_depth;\n#endif\n    s->sid_ctx_length = ctx->sid_ctx_length;\n    OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx);\n    memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx));\n    s->verify_callback = ctx->default_verify_callback;\n    s->generate_session_id = ctx->generate_session_id;\n    s->param = X509_VERIFY_PARAM_new();\n    if (!s->param)\n        goto err;\n    X509_VERIFY_PARAM_inherit(s->param, ctx->param);\n#if 0\n    s->purpose = ctx->purpose;\n    s->trust = ctx->trust;\n#endif\n    s->quiet_shutdown = ctx->quiet_shutdown;\n    s->max_send_fragment = ctx->max_send_fragment;\n    CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);\n    s->ctx = ctx;\n#ifndef OPENSSL_NO_TLSEXT\n    s->tlsext_debug_cb = 0;\n    s->tlsext_debug_arg = NULL;\n    s->tlsext_ticket_expected = 0;\n    s->tlsext_status_type = -1;\n    s->tlsext_status_expected = 0;\n    s->tlsext_ocsp_ids = NULL;\n    s->tlsext_ocsp_exts = NULL;\n    s->tlsext_ocsp_resp = NULL;\n    s->tlsext_ocsp_resplen = -1;\n    CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);\n    s->initial_ctx = ctx;\n# ifndef OPENSSL_NO_EC\n    if (ctx->tlsext_ecpointformatlist) {\n        s->tlsext_ecpointformatlist =\n            BUF_memdup(ctx->tlsext_ecpointformatlist,\n                       ctx->tlsext_ecpointformatlist_length);\n        if (!s->tlsext_ecpointformatlist)\n            goto err;\n        s->tlsext_ecpointformatlist_length =\n            ctx->tlsext_ecpointformatlist_length;\n    }\n    if (ctx->tlsext_ellipticcurvelist) {\n        s->tlsext_ellipticcurvelist =\n            BUF_memdup(ctx->tlsext_ellipticcurvelist,\n                       ctx->tlsext_ellipticcurvelist_length);\n        if (!s->tlsext_ellipticcurvelist)\n            goto err;\n        s->tlsext_ellipticcurvelist_length =\n            ctx->tlsext_ellipticcurvelist_length;\n    }\n# endif\n# ifndef OPENSSL_NO_NEXTPROTONEG\n    s->next_proto_negotiated = NULL;\n# endif\n    if (s->ctx->alpn_client_proto_list) {\n        s->alpn_client_proto_list =\n            OPENSSL_malloc(s->ctx->alpn_client_proto_list_len);\n        if (s->alpn_client_proto_list == NULL)\n            goto err;\n        memcpy(s->alpn_client_proto_list, s->ctx->alpn_client_proto_list,\n               s->ctx->alpn_client_proto_list_len);\n        s->alpn_client_proto_list_len = s->ctx->alpn_client_proto_list_len;\n    }\n#endif\n    s->verify_result = X509_V_OK;\n    s->method = ctx->method;\n    if (!s->method->ssl_new(s))\n        goto err;\n    s->references = 1;\n    s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;\n    SSL_clear(s);\n    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n#ifndef OPENSSL_NO_PSK\n    s->psk_client_callback = ctx->psk_client_callback;\n    s->psk_server_callback = ctx->psk_server_callback;\n#endif\n    return (s);\n err:\n    if (s != NULL)\n        SSL_free(s);\n    SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n    return (NULL);\n}', 'int SSL_clear(SSL *s)\n{\n    if (s->method == NULL) {\n        SSLerr(SSL_F_SSL_CLEAR, SSL_R_NO_METHOD_SPECIFIED);\n        return (0);\n    }\n    if (ssl_clear_bad_session(s)) {\n        SSL_SESSION_free(s->session);\n        s->session = NULL;\n    }\n    s->error = 0;\n    s->hit = 0;\n    s->shutdown = 0;\n#if 0\n    if (s->renegotiate)\n        return (1);\n#else\n    if (s->renegotiate) {\n        SSLerr(SSL_F_SSL_CLEAR, ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n#endif\n    s->type = 0;\n    s->state = SSL_ST_BEFORE | ((s->server) ? SSL_ST_ACCEPT : SSL_ST_CONNECT);\n    s->version = s->method->version;\n    s->client_version = s->version;\n    s->rwstate = SSL_NOTHING;\n    s->rstate = SSL_ST_READ_HEADER;\n#if 0\n    s->read_ahead = s->ctx->read_ahead;\n#endif\n    if (s->init_buf != NULL) {\n        BUF_MEM_free(s->init_buf);\n        s->init_buf = NULL;\n    }\n    ssl_clear_cipher_ctx(s);\n    ssl_clear_hash_ctx(&s->read_hash);\n    ssl_clear_hash_ctx(&s->write_hash);\n    s->first_packet = 0;\n#if 1\n    if (!s->in_handshake && (s->session == NULL)\n        && (s->method != s->ctx->method)) {\n        s->method->ssl_free(s);\n        s->method = s->ctx->method;\n        if (!s->method->ssl_new(s))\n            return (0);\n    } else\n#endif\n        s->method->ssl_clear(s);\n    return (1);\n}', 'int ssl_clear_bad_session(SSL *s)\n{\n    if ((s->session != NULL) &&\n        !(s->shutdown & SSL_SENT_SHUTDOWN) &&\n        !(SSL_in_init(s) || SSL_in_before(s))) {\n        SSL_CTX_remove_session(s->ctx, s->session);\n        return (1);\n    } else\n        return (0);\n}', 'int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)\n{\n    return remove_session_lock(ctx, c, 1);\n}', 'static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)\n{\n    SSL_SESSION *r;\n    int ret = 0;\n    if ((c != NULL) && (c->session_id_length != 0)) {\n        if (lck)\n            CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);\n        if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {\n            ret = 1;\n            r = lh_SSL_SESSION_delete(ctx->sessions, c);\n            SSL_SESSION_list_remove(ctx, c);\n        }\n        if (lck)\n            CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);\n        if (ret) {\n            r->not_resumable = 1;\n            if (ctx->remove_session_cb != NULL)\n                ctx->remove_session_cb(ctx, r);\n            SSL_SESSION_free(r);\n        }\n    } else\n        ret = 0;\n    return (ret);\n}', 'void *lh_delete(_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    LHASH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        lh->num_no_delete++;\n        return (NULL);\n    } else {\n        nn = *rn;\n        *rn = nn->next;\n        ret = nn->data;\n        OPENSSL_free(nn);\n        lh->num_delete++;\n    }\n    lh->num_items--;\n    if ((lh->num_nodes > MIN_NODES) &&\n        (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))\n        contract(lh);\n    return (ret);\n}']