ssl/s3_clnt.c:289: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `s->ctx->sessions->num_items`)] - 1):unsigned64 by call to `ssl3_client_hello`.
Showing all 13 steps of the trace


ssl/s3_clnt.c:182:1: Parameter `s->ctx->sessions->num_items`
180.                            ssl3_connect, ssl3_get_client_method)
181.   #endif
182. > int ssl3_connect(SSL *s)
183.   {
184.       BUF_MEM *buf = NULL;

ssl/s3_clnt.c:289:19: Call
287.   
288.               s->shutdown = 0;
289.               ret = ssl3_client_hello(s);
                         ^
290.               if (ret <= 0)
291.                   goto end;

ssl/s3_clnt.c:649:1: Parameter `s->ctx->sessions->num_items`
  647.   }
  648.   
  649. > int ssl3_client_hello(SSL *s)
  650.   {
  651.       unsigned char *buf;

ssl/s3_clnt.c:842:13: Call
  840.                ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH,
  841.                                           &al)) == NULL) {
  842.               ssl3_send_alert(s, SSL3_AL_FATAL, al);
                     ^
  843.               SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);
  844.               goto err;

ssl/s3_pkt.c:1760:1: Parameter `s->ctx->sessions->num_items`
    1758.   }
    1759.   
    1760. > int ssl3_send_alert(SSL *s, int level, int desc)
    1761.   {
    1762.       /* Map tls/ssl alert value to correct one */

ssl/s3_pkt.c:1771:9: Call
    1769.       /* If a fatal one, remove from cache */
    1770.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
    1771.           SSL_CTX_remove_session(s->ctx, s->session);
                    ^
    1772.   
    1773.       s->s3->alert_dispatch = 1;

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, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_client_hello` 
          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);
}
['int ssl3_connect(SSL *s)\n{\n    BUF_MEM *buf = NULL;\n    unsigned long Time = (unsigned long)time(NULL);\n    void (*cb) (const SSL *ssl, int type, int val) = NULL;\n    int ret = -1;\n    int new_state, state, skip = 0;\n    RAND_add(&Time, sizeof(Time), 0);\n    ERR_clear_error();\n    clear_sys_error();\n    if (s->info_callback != NULL)\n        cb = s->info_callback;\n    else if (s->ctx->info_callback != NULL)\n        cb = s->ctx->info_callback;\n    s->in_handshake++;\n    if (!SSL_in_init(s) || SSL_in_before(s))\n        SSL_clear(s);\n#ifndef OPENSSL_NO_HEARTBEATS\n    if (s->tlsext_hb_pending) {\n        s->tlsext_hb_pending = 0;\n        s->tlsext_hb_seq++;\n    }\n#endif\n    for (;;) {\n        state = s->state;\n        switch (s->state) {\n        case SSL_ST_RENEGOTIATE:\n            s->renegotiate = 1;\n            s->state = SSL_ST_CONNECT;\n            s->ctx->stats.sess_connect_renegotiate++;\n        case SSL_ST_BEFORE:\n        case SSL_ST_CONNECT:\n        case SSL_ST_BEFORE | SSL_ST_CONNECT:\n        case SSL_ST_OK | SSL_ST_CONNECT:\n            s->server = 0;\n            if (cb != NULL)\n                cb(s, SSL_CB_HANDSHAKE_START, 1);\n            if ((s->version & 0xff00) != 0x0300) {\n                SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);\n                ret = -1;\n                goto end;\n            }\n            if (!ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) {\n                SSLerr(SSL_F_SSL3_CONNECT, SSL_R_VERSION_TOO_LOW);\n                return -1;\n            }\n            s->type = SSL_ST_CONNECT;\n            if (s->init_buf == NULL) {\n                if ((buf = BUF_MEM_new()) == NULL) {\n                    ret = -1;\n                    goto end;\n                }\n                if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {\n                    ret = -1;\n                    goto end;\n                }\n                s->init_buf = buf;\n                buf = NULL;\n            }\n            if (!ssl3_setup_buffers(s)) {\n                ret = -1;\n                goto end;\n            }\n            if (!ssl_init_wbio_buffer(s, 0)) {\n                ret = -1;\n                goto end;\n            }\n            ssl3_init_finished_mac(s);\n            s->state = SSL3_ST_CW_CLNT_HELLO_A;\n            s->ctx->stats.sess_connect++;\n            s->init_num = 0;\n            s->s3->flags &= ~SSL3_FLAGS_CCS_OK;\n            s->s3->change_cipher_spec = 0;\n            break;\n        case SSL3_ST_CW_CLNT_HELLO_A:\n        case SSL3_ST_CW_CLNT_HELLO_B:\n            s->shutdown = 0;\n            ret = ssl3_client_hello(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_SRVR_HELLO_A;\n            s->init_num = 0;\n            if (s->bbio != s->wbio)\n                s->wbio = BIO_push(s->bbio, s->wbio);\n            break;\n        case SSL3_ST_CR_SRVR_HELLO_A:\n        case SSL3_ST_CR_SRVR_HELLO_B:\n            ret = ssl3_get_server_hello(s);\n            if (ret <= 0)\n                goto end;\n            if (s->hit) {\n                s->state = SSL3_ST_CR_FINISHED_A;\n#ifndef OPENSSL_NO_TLSEXT\n                if (s->tlsext_ticket_expected) {\n                    s->state = SSL3_ST_CR_SESSION_TICKET_A;\n                }\n#endif\n            } else {\n                s->state = SSL3_ST_CR_CERT_A;\n            }\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_CERT_A:\n        case SSL3_ST_CR_CERT_B:\n            if (!\n                (s->s3->tmp.\n                 new_cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))\n&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {\n                ret = ssl3_get_server_certificate(s);\n                if (ret <= 0)\n                    goto end;\n#ifndef OPENSSL_NO_TLSEXT\n                if (s->tlsext_status_expected)\n                    s->state = SSL3_ST_CR_CERT_STATUS_A;\n                else\n                    s->state = SSL3_ST_CR_KEY_EXCH_A;\n            } else {\n                skip = 1;\n                s->state = SSL3_ST_CR_KEY_EXCH_A;\n            }\n#else\n            } else\n                skip = 1;\n            s->state = SSL3_ST_CR_KEY_EXCH_A;\n#endif\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_KEY_EXCH_A:\n        case SSL3_ST_CR_KEY_EXCH_B:\n            ret = ssl3_get_key_exchange(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_CERT_REQ_A;\n            s->init_num = 0;\n            if (!ssl3_check_cert_and_algorithm(s)) {\n                ret = -1;\n                goto end;\n            }\n            break;\n        case SSL3_ST_CR_CERT_REQ_A:\n        case SSL3_ST_CR_CERT_REQ_B:\n            ret = ssl3_get_certificate_request(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_SRVR_DONE_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_SRVR_DONE_A:\n        case SSL3_ST_CR_SRVR_DONE_B:\n            ret = ssl3_get_server_done(s);\n            if (ret <= 0)\n                goto end;\n#ifndef OPENSSL_NO_SRP\n            if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) {\n                if ((ret = SRP_Calc_A_param(s)) <= 0) {\n                    SSLerr(SSL_F_SSL3_CONNECT, SSL_R_SRP_A_CALC);\n                    ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n                    goto end;\n                }\n            }\n#endif\n            if (s->s3->tmp.cert_req)\n                s->state = SSL3_ST_CW_CERT_A;\n            else\n                s->state = SSL3_ST_CW_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_CERT_A:\n        case SSL3_ST_CW_CERT_B:\n        case SSL3_ST_CW_CERT_C:\n        case SSL3_ST_CW_CERT_D:\n            ret = ssl3_send_client_certificate(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_KEY_EXCH_A:\n        case SSL3_ST_CW_KEY_EXCH_B:\n            ret = ssl3_send_client_key_exchange(s);\n            if (ret <= 0)\n                goto end;\n            if (s->s3->tmp.cert_req == 1) {\n                s->state = SSL3_ST_CW_CERT_VRFY_A;\n            } else {\n                s->state = SSL3_ST_CW_CHANGE_A;\n            }\n            if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) {\n                s->state = SSL3_ST_CW_CHANGE_A;\n            }\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_CERT_VRFY_A:\n        case SSL3_ST_CW_CERT_VRFY_B:\n            ret = ssl3_send_client_verify(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_CHANGE_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_CHANGE_A:\n        case SSL3_ST_CW_CHANGE_B:\n            ret = ssl3_send_change_cipher_spec(s,\n                                               SSL3_ST_CW_CHANGE_A,\n                                               SSL3_ST_CW_CHANGE_B);\n            if (ret <= 0)\n                goto end;\n#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)\n            s->state = SSL3_ST_CW_FINISHED_A;\n#else\n            if (s->s3->next_proto_neg_seen)\n                s->state = SSL3_ST_CW_NEXT_PROTO_A;\n            else\n                s->state = SSL3_ST_CW_FINISHED_A;\n#endif\n            s->init_num = 0;\n            s->session->cipher = s->s3->tmp.new_cipher;\n#ifdef OPENSSL_NO_COMP\n            s->session->compress_meth = 0;\n#else\n            if (s->s3->tmp.new_compression == NULL)\n                s->session->compress_meth = 0;\n            else\n                s->session->compress_meth = s->s3->tmp.new_compression->id;\n#endif\n            if (!s->method->ssl3_enc->setup_key_block(s)) {\n                ret = -1;\n                goto end;\n            }\n            if (!s->method->ssl3_enc->change_cipher_state(s,\n                                                          SSL3_CHANGE_CIPHER_CLIENT_WRITE))\n            {\n                ret = -1;\n                goto end;\n            }\n            break;\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)\n        case SSL3_ST_CW_NEXT_PROTO_A:\n        case SSL3_ST_CW_NEXT_PROTO_B:\n            ret = ssl3_send_next_proto(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_FINISHED_A;\n            break;\n#endif\n        case SSL3_ST_CW_FINISHED_A:\n        case SSL3_ST_CW_FINISHED_B:\n            ret = ssl3_send_finished(s,\n                                     SSL3_ST_CW_FINISHED_A,\n                                     SSL3_ST_CW_FINISHED_B,\n                                     s->method->\n                                     ssl3_enc->client_finished_label,\n                                     s->method->\n                                     ssl3_enc->client_finished_label_len);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_FLUSH;\n            s->s3->flags &= ~SSL3_FLAGS_POP_BUFFER;\n            if (s->hit) {\n                s->s3->tmp.next_state = SSL_ST_OK;\n                if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED) {\n                    s->state = SSL_ST_OK;\n                    s->s3->flags |= SSL3_FLAGS_POP_BUFFER;\n                    s->s3->delay_buf_pop_ret = 0;\n                }\n            } else {\n#ifndef OPENSSL_NO_TLSEXT\n                if (s->tlsext_ticket_expected)\n                    s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A;\n                else\n#endif\n                    s->s3->tmp.next_state = SSL3_ST_CR_FINISHED_A;\n            }\n            s->init_num = 0;\n            break;\n#ifndef OPENSSL_NO_TLSEXT\n        case SSL3_ST_CR_SESSION_TICKET_A:\n        case SSL3_ST_CR_SESSION_TICKET_B:\n            ret = ssl3_get_new_session_ticket(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_FINISHED_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_CERT_STATUS_A:\n        case SSL3_ST_CR_CERT_STATUS_B:\n            ret = ssl3_get_cert_status(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n#endif\n        case SSL3_ST_CR_FINISHED_A:\n        case SSL3_ST_CR_FINISHED_B:\n            s->s3->flags |= SSL3_FLAGS_CCS_OK;\n            ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A,\n                                    SSL3_ST_CR_FINISHED_B);\n            if (ret <= 0)\n                goto end;\n            if (s->hit)\n                s->state = SSL3_ST_CW_CHANGE_A;\n            else\n                s->state = SSL_ST_OK;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_FLUSH:\n            s->rwstate = SSL_WRITING;\n            if (BIO_flush(s->wbio) <= 0) {\n                ret = -1;\n                goto end;\n            }\n            s->rwstate = SSL_NOTHING;\n            s->state = s->s3->tmp.next_state;\n            break;\n        case SSL_ST_OK:\n            ssl3_cleanup_key_block(s);\n            if (s->init_buf != NULL) {\n                BUF_MEM_free(s->init_buf);\n                s->init_buf = NULL;\n            }\n            if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER))\n                ssl_free_wbio_buffer(s);\n            s->init_num = 0;\n            s->renegotiate = 0;\n            s->new_session = 0;\n            ssl_update_cache(s, SSL_SESS_CACHE_CLIENT);\n            if (s->hit)\n                s->ctx->stats.sess_hit++;\n            ret = 1;\n            s->handshake_func = ssl3_connect;\n            s->ctx->stats.sess_connect_good++;\n            if (cb != NULL)\n                cb(s, SSL_CB_HANDSHAKE_DONE, 1);\n            goto end;\n        default:\n            SSLerr(SSL_F_SSL3_CONNECT, SSL_R_UNKNOWN_STATE);\n            ret = -1;\n            goto end;\n        }\n        if (!s->s3->tmp.reuse_message && !skip) {\n            if (s->debug) {\n                if ((ret = BIO_flush(s->wbio)) <= 0)\n                    goto end;\n            }\n            if ((cb != NULL) && (s->state != state)) {\n                new_state = s->state;\n                s->state = state;\n                cb(s, SSL_CB_CONNECT_LOOP, 1);\n                s->state = new_state;\n            }\n        }\n        skip = 0;\n    }\n end:\n    s->in_handshake--;\n    if (buf != NULL)\n        BUF_MEM_free(buf);\n    if (cb != NULL)\n        cb(s, SSL_CB_CONNECT_EXIT, ret);\n    return (ret);\n}', 'int ssl3_client_hello(SSL *s)\n{\n    unsigned char *buf;\n    unsigned char *p, *d;\n    int i;\n    unsigned long l;\n    int al = 0;\n#ifndef OPENSSL_NO_COMP\n    int j;\n    SSL_COMP *comp;\n#endif\n    buf = (unsigned char *)s->init_buf->data;\n    if (s->state == SSL3_ST_CW_CLNT_HELLO_A) {\n        SSL_SESSION *sess = s->session;\n        if ((sess == NULL) ||\n            (sess->ssl_version != s->version) ||\n            !sess->session_id_length || (sess->not_resumable)) {\n            if (!ssl_get_new_session(s, 0))\n                goto err;\n        }\n        if (s->method->version == DTLS_ANY_VERSION) {\n            int options = s->options;\n            if (options & SSL_OP_NO_DTLSv1_2) {\n                if (tls1_suiteb(s)) {\n                    SSLerr(SSL_F_SSL3_CLIENT_HELLO,\n                           SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);\n                    goto err;\n                }\n                if (options & SSL_OP_NO_DTLSv1) {\n                    SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_WRONG_SSL_VERSION);\n                    goto err;\n                }\n                s->method = DTLSv1_client_method();\n                s->version = DTLS1_VERSION;\n            } else {\n                if (options & SSL_OP_NO_DTLSv1)\n                    s->method = DTLSv1_2_client_method();\n                s->version = DTLS1_2_VERSION;\n            }\n            s->client_version = s->version;\n        }\n        p = s->s3->client_random;\n        if (SSL_IS_DTLS(s)) {\n            size_t idx;\n            i = 1;\n            for (idx = 0; idx < sizeof(s->s3->client_random); idx++) {\n                if (p[idx]) {\n                    i = 0;\n                    break;\n                }\n            }\n        } else\n            i = 1;\n        if (i)\n            ssl_fill_hello_random(s, 0, p, sizeof(s->s3->client_random));\n        d = p = ssl_handshake_start(s);\n#if 0\n        *(p++) = s->version >> 8;\n        *(p++) = s->version & 0xff;\n        s->client_version = s->version;\n#else\n        *(p++) = s->client_version >> 8;\n        *(p++) = s->client_version & 0xff;\n#endif\n        memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE);\n        p += SSL3_RANDOM_SIZE;\n        if (s->new_session)\n            i = 0;\n        else\n            i = s->session->session_id_length;\n        *(p++) = i;\n        if (i != 0) {\n            if (i > (int)sizeof(s->session->session_id)) {\n                SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            memcpy(p, s->session->session_id, i);\n            p += i;\n        }\n        if (SSL_IS_DTLS(s)) {\n            if (s->d1->cookie_len > sizeof(s->d1->cookie)) {\n                SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            *(p++) = s->d1->cookie_len;\n            memcpy(p, s->d1->cookie, s->d1->cookie_len);\n            p += s->d1->cookie_len;\n        }\n        i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0);\n        if (i == 0) {\n            SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE);\n            goto err;\n        }\n#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH\n        if (TLS1_get_version(s) >= TLS1_2_VERSION\n            && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH)\n            i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1;\n#endif\n        s2n(i, p);\n        p += i;\n#ifdef OPENSSL_NO_COMP\n        *(p++) = 1;\n#else\n        if (!ssl_allow_compression(s) || !s->ctx->comp_methods)\n            j = 0;\n        else\n            j = sk_SSL_COMP_num(s->ctx->comp_methods);\n        *(p++) = 1 + j;\n        for (i = 0; i < j; i++) {\n            comp = sk_SSL_COMP_value(s->ctx->comp_methods, i);\n            *(p++) = comp->id;\n        }\n#endif\n        *(p++) = 0;\n#ifndef OPENSSL_NO_TLSEXT\n        if (ssl_prepare_clienthello_tlsext(s) <= 0) {\n            SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT);\n            goto err;\n        }\n        if ((p =\n             ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH,\n                                        &al)) == NULL) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, al);\n            SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n#endif\n        l = p - d;\n        ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l);\n        s->state = SSL3_ST_CW_CLNT_HELLO_B;\n    }\n    return ssl_do_write(s);\n err:\n    return (-1);\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\n    desc = s->method->ssl3_enc->alert_value(desc);\n    if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)\n        desc = SSL_AD_HANDSHAKE_FAILURE;\n    if (desc < 0)\n        return -1;\n    if ((level == SSL3_AL_FATAL) && (s->session != NULL))\n        SSL_CTX_remove_session(s->ctx, s->session);\n    s->s3->alert_dispatch = 1;\n    s->s3->send_alert[0] = level;\n    s->s3->send_alert[1] = desc;\n    if (s->s3->wbuf.left == 0)\n        return s->method->ssl_dispatch_alert(s);\n    return -1;\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}']