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


ssl/d1_clnt.c:159:1: Parameter `s->ctx->sessions->num_items`
157.                             dtls1_get_client_method, DTLSv1_2_enc_data)
158.   
159. > int dtls1_connect(SSL *s)
160.   {
161.       BUF_MEM *buf = NULL;

ssl/d1_clnt.c:445:19: Call
443.           case SSL3_ST_CR_CERT_REQ_A:
444.           case SSL3_ST_CR_CERT_REQ_B:
445.               ret = ssl3_get_certificate_request(s);
                         ^
446.               if (ret <= 0)
447.                   goto end;

ssl/s3_clnt.c:2011:1: Parameter `s->ctx->sessions->num_items`
  2009.   }
  2010.   
  2011. > int ssl3_get_certificate_request(SSL *s)
  2012.   {
  2013.       int ok, ret = 0;

ssl/s3_clnt.c:2145:13: Call
  2143.   
  2144.           if (namebytes != (namestart + name_len)) {
  2145.               ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
                      ^
  2146.               SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,
  2147.                      SSL_R_CA_DN_LENGTH_MISMATCH);

ssl/s3_msg.c:166:1: Parameter `s->ctx->sessions->num_items`
    164.   }
    165.   
    166. > int ssl3_send_alert(SSL *s, int level, int desc)
    167.   {
    168.       /* Map tls/ssl alert value to correct one */

ssl/s3_msg.c:177:9: Call
    175.       /* If a fatal one, remove from cache */
    176.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
    177.           SSL_CTX_remove_session(s->ctx, s->session);
                   ^
    178.   
    179.       s->s3->alert_dispatch = 1;

ssl/ssl_sess.c:787:1: Parameter `ctx->sessions->num_items`
      785.   }
      786.   
      787. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      788.   {
      789.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:789:12: Call
      787.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      788.   {
      789.       return remove_session_lock(ctx, c, 1);
                        ^
      790.   }
      791.   

ssl/ssl_sess.c:792:1: Parameter `ctx->sessions->num_items`
        790.   }
        791.   
        792. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        793.   {
        794.       SSL_SESSION *r;

ssl/ssl_sess.c:802:17: Call
        800.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
        801.               ret = 1;
        802.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                               ^
        803.               SSL_SESSION_list_remove(ctx, c);
        804.           }

crypto/lhash/lhash.c:209:1: <LHS trace>
207.   }
208.   
209. > void *lh_delete(_LHASH *lh, const void *data)
210.   {
211.       unsigned long hash;

crypto/lhash/lhash.c:209:1: Parameter `lh->num_items`
          207.   }
          208.   
          209. > void *lh_delete(_LHASH *lh, const void *data)
          210.   {
          211.       unsigned long hash;

crypto/lhash/lhash.c:229:5: Binary operation: ([0, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_get_certificate_request` 
          227.       }
          228.   
          229.       lh->num_items--;
                     ^
          230.       if ((lh->num_nodes > MIN_NODES) &&
          231.           (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 dtls1_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#ifndef OPENSSL_NO_SCTP\n    unsigned char sctpauthkey[64];\n    char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)];\n#endif\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        if (!SSL_clear(s))\n            return -1;\n    }\n#ifndef OPENSSL_NO_SCTP\n    BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,\n             s->in_handshake, NULL);\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n    if (s->tlsext_hb_pending) {\n        dtls1_stop_timer(s);\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) != (DTLS1_VERSION & 0xff00) &&\n                (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00)) {\n                SSLerr(SSL_F_DTLS1_CONNECT, ERR_R_INTERNAL_ERROR);\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            s->type = SSL_ST_CONNECT;\n            if (s->init_buf == NULL) {\n                if ((buf = BUF_MEM_new()) == NULL) {\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n                if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n                s->init_buf = buf;\n                buf = NULL;\n            }\n            if (!ssl3_setup_buffers(s)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            if (!ssl_init_wbio_buffer(s, 0)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            s->state = SSL3_ST_CW_CLNT_HELLO_A;\n            s->ctx->stats.sess_connect++;\n            s->init_num = 0;\n            memset(s->s3->client_random, 0, sizeof(s->s3->client_random));\n            s->d1->send_cookie = 0;\n            s->hit = 0;\n            s->s3->change_cipher_spec = 0;\n            break;\n#ifndef OPENSSL_NO_SCTP\n        case DTLS1_SCTP_ST_CR_READ_SOCK:\n            if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) {\n                s->s3->in_read_app_data = 2;\n                s->rwstate = SSL_READING;\n                BIO_clear_retry_flags(SSL_get_rbio(s));\n                BIO_set_retry_read(SSL_get_rbio(s));\n                ret = -1;\n                goto end;\n            }\n            s->state = s->s3->tmp.next_state;\n            break;\n        case DTLS1_SCTP_ST_CW_WRITE_SOCK:\n            ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s));\n            if (ret < 0)\n                goto end;\n            if (ret == 0) {\n                s->s3->in_read_app_data = 2;\n                s->rwstate = SSL_READING;\n                BIO_clear_retry_flags(SSL_get_rbio(s));\n                BIO_set_retry_read(SSL_get_rbio(s));\n                ret = -1;\n                goto end;\n            }\n            s->state = s->d1->next_state;\n            break;\n#endif\n        case SSL3_ST_CW_CLNT_HELLO_A:\n        case SSL3_ST_CW_CLNT_HELLO_B:\n            s->shutdown = 0;\n            ssl3_init_finished_mac(s);\n            dtls1_start_timer(s);\n            ret = ssl3_client_hello(s);\n            if (ret <= 0)\n                goto end;\n            if (s->d1->send_cookie) {\n                s->state = SSL3_ST_CW_FLUSH;\n                s->s3->tmp.next_state = SSL3_ST_CR_SRVR_HELLO_A;\n            } else\n                s->state = SSL3_ST_CR_SRVR_HELLO_A;\n            s->init_num = 0;\n#ifndef OPENSSL_NO_SCTP\n            if (!BIO_dgram_is_sctp(SSL_get_wbio(s))) {\n#endif\n                if (s->bbio != s->wbio)\n                    s->wbio = BIO_push(s->bbio, s->wbio);\n#ifndef OPENSSL_NO_SCTP\n            }\n#endif\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            else {\n                if (s->hit) {\n#ifndef OPENSSL_NO_SCTP\n                    snprintf((char *)labelbuffer,\n                             sizeof(DTLS1_SCTP_AUTH_LABEL),\n                             DTLS1_SCTP_AUTH_LABEL);\n                    if (SSL_export_keying_material(s, sctpauthkey,\n                                               sizeof(sctpauthkey),\n                                               labelbuffer,\n                                               sizeof(labelbuffer), NULL, 0,\n                                               0) <= 0) {\n                        ret = -1;\n                        s->state = SSL_ST_ERR;\n                        goto end;\n                    }\n                    BIO_ctrl(SSL_get_wbio(s),\n                             BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY,\n                             sizeof(sctpauthkey), sctpauthkey);\n#endif\n                    s->state = SSL3_ST_CR_CHANGE_A;\n                } else\n                    s->state = DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A;\n            }\n            s->init_num = 0;\n            break;\n        case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:\n        case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:\n            ret = dtls1_get_hello_verify(s);\n            if (ret <= 0)\n                goto end;\n            dtls1_stop_timer(s);\n            if (s->d1->send_cookie)\n                s->state = SSL3_ST_CW_CLNT_HELLO_A;\n            else\n                s->state = SSL3_ST_CR_CERT_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_CERT_A:\n        case SSL3_ST_CR_CERT_B:\n            if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&\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                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            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                s->state = SSL_ST_ERR;\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            dtls1_stop_timer(s);\n            if (s->s3->tmp.cert_req)\n                s->s3->tmp.next_state = SSL3_ST_CW_CERT_A;\n            else\n                s->s3->tmp.next_state = SSL3_ST_CW_KEY_EXCH_A;\n            s->init_num = 0;\n#ifndef OPENSSL_NO_SCTP\n            if (BIO_dgram_is_sctp(SSL_get_wbio(s)) &&\n                state == SSL_ST_RENEGOTIATE)\n                s->state = DTLS1_SCTP_ST_CR_READ_SOCK;\n            else\n#endif\n                s->state = s->s3->tmp.next_state;\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            dtls1_start_timer(s);\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            dtls1_start_timer(s);\n            ret = ssl3_send_client_key_exchange(s);\n            if (ret <= 0)\n                goto end;\n#ifndef OPENSSL_NO_SCTP\n            snprintf((char *)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL),\n                     DTLS1_SCTP_AUTH_LABEL);\n            if (SSL_export_keying_material(s, sctpauthkey,\n                                       sizeof(sctpauthkey), labelbuffer,\n                                       sizeof(labelbuffer), NULL, 0, 0) <= 0) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY,\n                     sizeof(sctpauthkey), sctpauthkey);\n#endif\n            if (s->s3->tmp.cert_req == 1) {\n                s->state = SSL3_ST_CW_CERT_VRFY_A;\n            } else {\n#ifndef OPENSSL_NO_SCTP\n                if (BIO_dgram_is_sctp(SSL_get_wbio(s))) {\n                    s->d1->next_state = SSL3_ST_CW_CHANGE_A;\n                    s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK;\n                } else\n#endif\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            dtls1_start_timer(s);\n            ret = ssl3_send_client_verify(s);\n            if (ret <= 0)\n                goto end;\n#ifndef OPENSSL_NO_SCTP\n            if (BIO_dgram_is_sctp(SSL_get_wbio(s))) {\n                s->d1->next_state = SSL3_ST_CW_CHANGE_A;\n                s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK;\n            } else\n#endif\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            if (!s->hit)\n                dtls1_start_timer(s);\n            ret = dtls1_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            s->state = SSL3_ST_CW_FINISHED_A;\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                s->state = SSL_ST_ERR;\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                s->state = SSL_ST_ERR;\n                goto end;\n            }\n#ifndef OPENSSL_NO_SCTP\n            if (s->hit) {\n                BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY,\n                         0, NULL);\n            }\n#endif\n            dtls1_reset_seq_numbers(s, SSL3_CC_WRITE);\n            break;\n        case SSL3_ST_CW_FINISHED_A:\n        case SSL3_ST_CW_FINISHED_B:\n            if (!s->hit)\n                dtls1_start_timer(s);\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            if (s->hit) {\n                s->s3->tmp.next_state = SSL_ST_OK;\n#ifndef OPENSSL_NO_SCTP\n                if (BIO_dgram_is_sctp(SSL_get_wbio(s))) {\n                    s->d1->next_state = s->s3->tmp.next_state;\n                    s->s3->tmp.next_state = DTLS1_SCTP_ST_CW_WRITE_SOCK;\n                }\n#endif\n            } else {\n#ifndef OPENSSL_NO_SCTP\n                BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY,\n                         0, NULL);\n#endif\n                if (s->tlsext_ticket_expected)\n                    s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A;\n                else\n                    s->s3->tmp.next_state = SSL3_ST_CR_CHANGE_A;\n            }\n            s->init_num = 0;\n            break;\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_CHANGE_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        case SSL3_ST_CR_CHANGE_A:\n        case SSL3_ST_CR_CHANGE_B:\n            ret = ssl3_get_change_cipher_spec(s, SSL3_ST_CR_CHANGE_A,\n                                              SSL3_ST_CR_CHANGE_B);\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_FINISHED_A:\n        case SSL3_ST_CR_FINISHED_B:\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            dtls1_stop_timer(s);\n            if (s->hit)\n                s->state = SSL3_ST_CW_CHANGE_A;\n            else\n                s->state = SSL_ST_OK;\n#ifndef OPENSSL_NO_SCTP\n            if (BIO_dgram_is_sctp(SSL_get_wbio(s)) &&\n                state == SSL_ST_RENEGOTIATE) {\n                s->d1->next_state = s->state;\n                s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK;\n            }\n#endif\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                if (!BIO_should_retry(s->wbio)) {\n                    s->rwstate = SSL_NOTHING;\n                    s->state = s->s3->tmp.next_state;\n                }\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            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 = dtls1_connect;\n            s->ctx->stats.sess_connect_good++;\n            if (cb != NULL)\n                cb(s, SSL_CB_HANDSHAKE_DONE, 1);\n            s->d1->handshake_read_seq = 0;\n            s->d1->next_handshake_write_seq = 0;\n            goto end;\n        case SSL_ST_ERR:\n        default:\n            SSLerr(SSL_F_DTLS1_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#ifndef OPENSSL_NO_SCTP\n    BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,\n             s->in_handshake, NULL);\n#endif\n    BUF_MEM_free(buf);\n    if (cb != NULL)\n        cb(s, SSL_CB_CONNECT_EXIT, ret);\n    return (ret);\n}', 'int ssl3_get_certificate_request(SSL *s)\n{\n    int ok, ret = 0;\n    unsigned long n;\n    unsigned int list_len, ctype_num, i, name_len;\n    X509_NAME *xn = NULL;\n    unsigned char *data;\n    unsigned char *namestart, *namebytes;\n    STACK_OF(X509_NAME) *ca_sk = NULL;\n    PACKET pkt;\n    n = s->method->ssl_get_message(s,\n                                   SSL3_ST_CR_CERT_REQ_A,\n                                   SSL3_ST_CR_CERT_REQ_B,\n                                   -1, s->max_cert_list, &ok);\n    if (!ok)\n        return ((int)n);\n    s->s3->tmp.cert_req = 0;\n    if (s->s3->tmp.message_type == SSL3_MT_SERVER_DONE) {\n        s->s3->tmp.reuse_message = 1;\n        if (!ssl3_digest_cached_records(s, 0))\n            goto err;\n        return (1);\n    }\n    if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_REQUEST) {\n        ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);\n        SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_WRONG_MESSAGE_TYPE);\n        goto err;\n    }\n    if (s->version > SSL3_VERSION) {\n        if (s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,\n                   SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER);\n            goto err;\n        }\n    }\n    if (!PACKET_buf_init(&pkt, s->init_msg, n)) {\n        ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n        SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    if ((ca_sk = sk_X509_NAME_new(ca_dn_cmp)) == NULL) {\n        SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!PACKET_get_1(&pkt, &ctype_num)\n            || !PACKET_get_bytes(&pkt, &data, ctype_num)) {\n        ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n        SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH);\n        goto err;\n    }\n    OPENSSL_free(s->cert->ctypes);\n    s->cert->ctypes = NULL;\n    if (ctype_num > SSL3_CT_NUMBER) {\n        s->cert->ctypes = OPENSSL_malloc(ctype_num);\n        if (s->cert->ctypes == NULL) {\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        memcpy(s->cert->ctypes, data, ctype_num);\n        s->cert->ctype_num = (size_t)ctype_num;\n        ctype_num = SSL3_CT_NUMBER;\n    }\n    for (i = 0; i < ctype_num; i++)\n        s->s3->tmp.ctype[i] = data[i];\n    if (SSL_USE_SIGALGS(s)) {\n        if (!PACKET_get_net_2(&pkt, &list_len)\n                || !PACKET_get_bytes(&pkt, &data, list_len)) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH);\n            goto err;\n        }\n        for (i = 0; i < SSL_PKEY_NUM; i++) {\n            s->s3->tmp.md[i] = NULL;\n            s->s3->tmp.valid_flags[i] = 0;\n        }\n        if ((list_len & 1) || !tls1_save_sigalgs(s, data, list_len)) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,\n                   SSL_R_SIGNATURE_ALGORITHMS_ERROR);\n            goto err;\n        }\n        if (!tls1_process_sigalgs(s)) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n    if (!PACKET_get_net_2(&pkt, &list_len)\n            || PACKET_remaining(&pkt) != list_len) {\n        ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n        SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH);\n        goto err;\n    }\n    while (PACKET_remaining(&pkt)) {\n        if (!PACKET_get_net_2(&pkt, &name_len)\n                || !PACKET_get_bytes(&pkt, &namebytes, name_len)) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH);\n            goto err;\n        }\n        namestart = namebytes;\n        if ((xn = d2i_X509_NAME(NULL, (const unsigned char **)&namebytes,\n                                name_len)) == NULL) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_ASN1_LIB);\n            goto err;\n        }\n        if (namebytes != (namestart + name_len)) {\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,\n                   SSL_R_CA_DN_LENGTH_MISMATCH);\n            goto err;\n        }\n        if (!sk_X509_NAME_push(ca_sk, xn)) {\n            SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n    s->s3->tmp.cert_req = 1;\n    s->s3->tmp.ctype_num = ctype_num;\n    sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);\n    s->s3->tmp.ca_names = ca_sk;\n    ca_sk = NULL;\n    ret = 1;\n    goto done;\n err:\n    s->state = SSL_ST_ERR;\n done:\n    sk_X509_NAME_pop_free(ca_sk, X509_NAME_free);\n    return (ret);\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 (!RECORD_LAYER_write_pending(&s->rlayer)) {\n        return s->method->ssl_dispatch_alert(s);\n    }\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}']