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_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)\n{\n    int al, i, j, ret;\n    unsigned int n;\n    SSL3_RECORD *rr;\n    void (*cb) (const SSL *ssl, int type2, int val) = NULL;\n    if (!SSL3_BUFFER_is_initialised(&s->rlayer.rbuf)) {\n        if (!ssl3_setup_read_buffer(s))\n            return (-1);\n    }\n    if ((type && (type != SSL3_RT_APPLICATION_DATA)\n         && (type != SSL3_RT_HANDSHAKE)) || (peek\n                                             && (type !=\n                                                 SSL3_RT_APPLICATION_DATA))) {\n        SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR);\n        return -1;\n    }\n    if ((type == SSL3_RT_HANDSHAKE) && (s->rlayer.handshake_fragment_len > 0))\n    {\n        unsigned char *src = s->rlayer.handshake_fragment;\n        unsigned char *dst = buf;\n        unsigned int k;\n        n = 0;\n        while ((len > 0) && (s->rlayer.handshake_fragment_len > 0)) {\n            *dst++ = *src++;\n            len--;\n            s->rlayer.handshake_fragment_len--;\n            n++;\n        }\n        for (k = 0; k < s->rlayer.handshake_fragment_len; k++)\n            s->rlayer.handshake_fragment[k] = *src++;\n        return n;\n    }\n    if (!s->in_handshake && SSL_in_init(s)) {\n        i = s->handshake_func(s);\n        if (i < 0)\n            return (i);\n        if (i == 0) {\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE);\n            return (-1);\n        }\n    }\n start:\n    s->rwstate = SSL_NOTHING;\n    rr = &s->rlayer.rrec;\n    if ((SSL3_RECORD_get_length(rr) == 0)\n            || (s->rlayer.rstate == SSL_ST_READ_BODY)) {\n        ret = ssl3_get_record(s);\n        if (ret <= 0)\n            return (ret);\n    }\n    if (s->s3->change_cipher_spec\n        && (SSL3_RECORD_get_type(rr) != SSL3_RT_HANDSHAKE)) {\n        al = SSL_AD_UNEXPECTED_MESSAGE;\n        SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_DATA_BETWEEN_CCS_AND_FINISHED);\n        goto f_err;\n    }\n    if (s->shutdown & SSL_RECEIVED_SHUTDOWN) {\n        SSL3_RECORD_set_length(rr, 0);\n        s->rwstate = SSL_NOTHING;\n        return (0);\n    }\n    if (type == SSL3_RECORD_get_type(rr)) {\n        if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&\n            (s->enc_read_ctx == NULL)) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_APP_DATA_IN_HANDSHAKE);\n            goto f_err;\n        }\n        if (len <= 0)\n            return (len);\n        if ((unsigned int)len > SSL3_RECORD_get_length(rr))\n            n = SSL3_RECORD_get_length(rr);\n        else\n            n = (unsigned int)len;\n        memcpy(buf, &(rr->data[rr->off]), n);\n        if (!peek) {\n            SSL3_RECORD_add_length(rr, -n);\n            SSL3_RECORD_add_off(rr, n);\n            if (SSL3_RECORD_get_length(rr) == 0) {\n                s->rlayer.rstate = SSL_ST_READ_HEADER;\n                SSL3_RECORD_set_off(rr, 0);\n                if (s->mode & SSL_MODE_RELEASE_BUFFERS\n                    && SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0)\n                    ssl3_release_read_buffer(s);\n            }\n        }\n        return (n);\n    }\n    {\n        unsigned int dest_maxlen = 0;\n        unsigned char *dest = NULL;\n        unsigned int *dest_len = NULL;\n        if (SSL3_RECORD_get_type(rr) == SSL3_RT_HANDSHAKE) {\n            dest_maxlen = sizeof s->rlayer.handshake_fragment;\n            dest = s->rlayer.handshake_fragment;\n            dest_len = &s->rlayer.handshake_fragment_len;\n        } else if (SSL3_RECORD_get_type(rr) == SSL3_RT_ALERT) {\n            dest_maxlen = sizeof s->rlayer.alert_fragment;\n            dest = s->rlayer.alert_fragment;\n            dest_len = &s->rlayer.alert_fragment_len;\n        }\n#ifndef OPENSSL_NO_HEARTBEATS\n        else if (SSL3_RECORD_get_type(rr)== TLS1_RT_HEARTBEAT) {\n            if(tls1_process_heartbeat(s, SSL3_RECORD_get_data(rr),\n                    SSL3_RECORD_get_length(rr)) < 0) {\n                return -1;\n            }\n            SSL3_RECORD_set_length(rr, 0);\n            s->rwstate = SSL_READING;\n            BIO_clear_retry_flags(SSL_get_rbio(s));\n            BIO_set_retry_read(SSL_get_rbio(s));\n            return (-1);\n        }\n#endif\n        if (dest_maxlen > 0) {\n            n = dest_maxlen - *dest_len;\n            if (SSL3_RECORD_get_length(rr) < n)\n                n = SSL3_RECORD_get_length(rr);\n            while (n-- > 0) {\n                dest[(*dest_len)++] =\n                    SSL3_RECORD_get_data(rr)[SSL3_RECORD_get_off(rr)];\n                SSL3_RECORD_add_off(rr, 1);\n                SSL3_RECORD_add_length(rr, -1);\n            }\n            if (*dest_len < dest_maxlen)\n                goto start;\n        }\n    }\n    if ((!s->server) &&\n        (s->rlayer.handshake_fragment_len >= 4) &&\n        (s->rlayer.handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) &&\n        (s->session != NULL) && (s->session->cipher != NULL)) {\n        s->rlayer.handshake_fragment_len = 0;\n        if ((s->rlayer.handshake_fragment[1] != 0) ||\n            (s->rlayer.handshake_fragment[2] != 0) ||\n            (s->rlayer.handshake_fragment[3] != 0)) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_BAD_HELLO_REQUEST);\n            goto f_err;\n        }\n        if (s->msg_callback)\n            s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,\n                            s->rlayer.handshake_fragment, 4, s,\n                            s->msg_callback_arg);\n        if (SSL_is_init_finished(s) &&\n            !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&\n            !s->s3->renegotiate) {\n            ssl3_renegotiate(s);\n            if (ssl3_renegotiate_check(s)) {\n                i = s->handshake_func(s);\n                if (i < 0)\n                    return (i);\n                if (i == 0) {\n                    SSLerr(SSL_F_SSL3_READ_BYTES,\n                           SSL_R_SSL_HANDSHAKE_FAILURE);\n                    return (-1);\n                }\n                if (!(s->mode & SSL_MODE_AUTO_RETRY)) {\n                    if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {\n                        BIO *bio;\n                        s->rwstate = SSL_READING;\n                        bio = SSL_get_rbio(s);\n                        BIO_clear_retry_flags(bio);\n                        BIO_set_retry_read(bio);\n                        return (-1);\n                    }\n                }\n            }\n        }\n        goto start;\n    }\n    if (s->server &&\n        SSL_is_init_finished(s) &&\n        !s->s3->send_connection_binding &&\n        (s->version > SSL3_VERSION) &&\n        (s->rlayer.handshake_fragment_len >= 4) &&\n        (s->rlayer.handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) &&\n        (s->session != NULL) && (s->session->cipher != NULL) &&\n        !(s->ctx->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {\n        SSL3_RECORD_set_length(rr, 0);\n        ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_RENEGOTIATION);\n        goto start;\n    }\n    if (s->rlayer.alert_fragment_len >= 2) {\n        int alert_level = s->rlayer.alert_fragment[0];\n        int alert_descr = s->rlayer.alert_fragment[1];\n        s->rlayer.alert_fragment_len = 0;\n        if (s->msg_callback)\n            s->msg_callback(0, s->version, SSL3_RT_ALERT,\n                            s->rlayer.alert_fragment, 2, s,\n                            s->msg_callback_arg);\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        if (cb != NULL) {\n            j = (alert_level << 8) | alert_descr;\n            cb(s, SSL_CB_READ_ALERT, j);\n        }\n        if (alert_level == SSL3_AL_WARNING) {\n            s->s3->warn_alert = alert_descr;\n            if (alert_descr == SSL_AD_CLOSE_NOTIFY) {\n                s->shutdown |= SSL_RECEIVED_SHUTDOWN;\n                return (0);\n            }\n            else if (alert_descr == SSL_AD_NO_RENEGOTIATION) {\n                al = SSL_AD_HANDSHAKE_FAILURE;\n                SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_NO_RENEGOTIATION);\n                goto f_err;\n            }\n#ifdef SSL_AD_MISSING_SRP_USERNAME\n            else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME)\n                return (0);\n#endif\n        } else if (alert_level == SSL3_AL_FATAL) {\n            char tmp[16];\n            s->rwstate = SSL_NOTHING;\n            s->s3->fatal_alert = alert_descr;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr);\n            BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr);\n            ERR_add_error_data(2, "SSL alert number ", tmp);\n            s->shutdown |= SSL_RECEIVED_SHUTDOWN;\n            SSL_CTX_remove_session(s->ctx, s->session);\n            return (0);\n        } else {\n            al = SSL_AD_ILLEGAL_PARAMETER;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNKNOWN_ALERT_TYPE);\n            goto f_err;\n        }\n        goto start;\n    }\n    if (s->shutdown & SSL_SENT_SHUTDOWN) {\n        s->rwstate = SSL_NOTHING;\n        SSL3_RECORD_set_length(rr, 0);\n        return (0);\n    }\n    if (SSL3_RECORD_get_type(rr) == SSL3_RT_CHANGE_CIPHER_SPEC) {\n        if ((SSL3_RECORD_get_length(rr) != 1)\n            || (SSL3_RECORD_get_off(rr) != 0)\n            || (SSL3_RECORD_get_data(rr)[0] != SSL3_MT_CCS)) {\n            al = SSL_AD_ILLEGAL_PARAMETER;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_BAD_CHANGE_CIPHER_SPEC);\n            goto f_err;\n        }\n        if (s->s3->tmp.new_cipher == NULL) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_CCS_RECEIVED_EARLY);\n            goto f_err;\n        }\n        if (!(s->s3->flags & SSL3_FLAGS_CCS_OK)) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_CCS_RECEIVED_EARLY);\n            goto f_err;\n        }\n        s->s3->flags &= ~SSL3_FLAGS_CCS_OK;\n        SSL3_RECORD_set_length(rr, 0);\n        if (s->msg_callback)\n            s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC,\n                            SSL3_RECORD_get_data(rr), 1, s,\n                            s->msg_callback_arg);\n        s->s3->change_cipher_spec = 1;\n        if (!ssl3_do_change_cipher_spec(s))\n            goto err;\n        else\n            goto start;\n    }\n    if ((s->rlayer.handshake_fragment_len >= 4) && !s->in_handshake) {\n        if (((s->state & SSL_ST_MASK) == SSL_ST_OK) &&\n            !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) {\n            s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT;\n            s->renegotiate = 1;\n            s->new_session = 1;\n        }\n        i = s->handshake_func(s);\n        if (i < 0)\n            return (i);\n        if (i == 0) {\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE);\n            return (-1);\n        }\n        if (!(s->mode & SSL_MODE_AUTO_RETRY)) {\n            if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {\n                BIO *bio;\n                s->rwstate = SSL_READING;\n                bio = SSL_get_rbio(s);\n                BIO_clear_retry_flags(bio);\n                BIO_set_retry_read(bio);\n                return (-1);\n            }\n        }\n        goto start;\n    }\n    switch (SSL3_RECORD_get_type(rr)) {\n    default:\n        if (s->version >= TLS1_VERSION && s->version <= TLS1_1_VERSION) {\n            SSL3_RECORD_set_length(rr, 0);\n            goto start;\n        }\n        al = SSL_AD_UNEXPECTED_MESSAGE;\n        SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNEXPECTED_RECORD);\n        goto f_err;\n    case SSL3_RT_CHANGE_CIPHER_SPEC:\n    case SSL3_RT_ALERT:\n    case SSL3_RT_HANDSHAKE:\n        al = SSL_AD_UNEXPECTED_MESSAGE;\n        SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR);\n        goto f_err;\n    case SSL3_RT_APPLICATION_DATA:\n        if (s->s3->in_read_app_data &&\n            (s->s3->total_renegotiations != 0) &&\n            (((s->state & SSL_ST_CONNECT) &&\n              (s->state >= SSL3_ST_CW_CLNT_HELLO_A) &&\n              (s->state <= SSL3_ST_CR_SRVR_HELLO_A)\n             ) || ((s->state & SSL_ST_ACCEPT) &&\n                   (s->state <= SSL3_ST_SW_HELLO_REQ_A) &&\n                   (s->state >= SSL3_ST_SR_CLNT_HELLO_A)\n             )\n            )) {\n            s->s3->in_read_app_data = 2;\n            return (-1);\n        } else {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNEXPECTED_RECORD);\n            goto f_err;\n        }\n    }\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    return (-1);\n}', 'int ssl3_get_record(SSL *s)\n{\n    int ssl_major, ssl_minor, al;\n    int enc_err, n, i, ret = -1;\n    SSL3_RECORD *rr;\n    SSL_SESSION *sess;\n    unsigned char *p;\n    unsigned char md[EVP_MAX_MD_SIZE];\n    short version;\n    unsigned mac_size;\n    size_t extra;\n    unsigned empty_record_count = 0;\n    rr = RECORD_LAYER_get_rrec(&s->rlayer);\n    sess = s->session;\n    if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)\n        extra = SSL3_RT_MAX_EXTRA;\n    else\n        extra = 0;\n    if (extra && !s->s3->init_extra) {\n        SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR);\n        return -1;\n    }\n again:\n    if ((RECORD_LAYER_get_rstate(&s->rlayer) != SSL_ST_READ_BODY) ||\n        (RECORD_LAYER_get_packet_length(&s->rlayer) < SSL3_RT_HEADER_LENGTH)) {\n        n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH,\n            SSL3_BUFFER_get_len(&s->rlayer.rbuf), 0);\n        if (n <= 0)\n            return (n);\n        RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_BODY);\n        p = RECORD_LAYER_get_packet(&s->rlayer);\n        if (s->msg_callback)\n            s->msg_callback(0, 0, SSL3_RT_HEADER, p, 5, s,\n                            s->msg_callback_arg);\n        rr->type = *(p++);\n        ssl_major = *(p++);\n        ssl_minor = *(p++);\n        version = (ssl_major << 8) | ssl_minor;\n        n2s(p, rr->length);\n        if (!s->first_packet) {\n            if (version != s->version) {\n                SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);\n                if ((s->version & 0xFF00) == (version & 0xFF00)\n                    && !s->enc_write_ctx && !s->write_hash)\n                    s->version = (unsigned short)version;\n                al = SSL_AD_PROTOCOL_VERSION;\n                goto f_err;\n            }\n        }\n        if ((version >> 8) != SSL3_VERSION_MAJOR) {\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);\n            goto err;\n        }\n        if (rr->length >\n                SSL3_BUFFER_get_len(&s->rlayer.rbuf)\n                - SSL3_RT_HEADER_LENGTH) {\n            al = SSL_AD_RECORD_OVERFLOW;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG);\n            goto f_err;\n        }\n    }\n    if (rr->length >\n        RECORD_LAYER_get_packet_length(&s->rlayer) - SSL3_RT_HEADER_LENGTH) {\n        i = rr->length;\n        n = ssl3_read_n(s, i, i, 1);\n        if (n <= 0)\n            return (n);\n    }\n    RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_HEADER);\n    rr->input = &(RECORD_LAYER_get_packet(&s->rlayer)[SSL3_RT_HEADER_LENGTH]);\n    if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH + extra) {\n        al = SSL_AD_RECORD_OVERFLOW;\n        SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_ENCRYPTED_LENGTH_TOO_LONG);\n        goto f_err;\n    }\n    rr->data = rr->input;\n    rr->orig_len = rr->length;\n    if (SSL_USE_ETM(s) && s->read_hash) {\n        unsigned char *mac;\n        mac_size = EVP_MD_CTX_size(s->read_hash);\n        OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);\n        if (rr->length < mac_size) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        rr->length -= mac_size;\n        mac = rr->data + rr->length;\n        i = s->method->ssl3_enc->mac(s, md, 0   );\n        if (i < 0 || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0) {\n            al = SSL_AD_BAD_RECORD_MAC;\n            SSLerr(SSL_F_SSL3_GET_RECORD,\n                   SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);\n            goto f_err;\n        }\n    }\n    enc_err = s->method->ssl3_enc->enc(s, 0);\n    if (enc_err == 0) {\n        al = SSL_AD_DECRYPTION_FAILED;\n        SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);\n        goto f_err;\n    }\n#ifdef TLS_DEBUG\n    printf("dec %d\\n", rr->length);\n    {\n        unsigned int z;\n        for (z = 0; z < rr->length; z++)\n            printf("%02X%c", rr->data[z], ((z + 1) % 16) ? \' \' : \'\\n\');\n    }\n    printf("\\n");\n#endif\n    if ((sess != NULL) &&\n        (s->enc_read_ctx != NULL) &&\n        (EVP_MD_CTX_md(s->read_hash) != NULL) && !SSL_USE_ETM(s)) {\n        unsigned char *mac = NULL;\n        unsigned char mac_tmp[EVP_MAX_MD_SIZE];\n        mac_size = EVP_MD_CTX_size(s->read_hash);\n        OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);\n        if (rr->orig_len < mac_size ||\n            (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&\n             rr->orig_len < mac_size + 1)) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) {\n            mac = mac_tmp;\n            ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);\n            rr->length -= mac_size;\n        } else {\n            rr->length -= mac_size;\n            mac = &rr->data[rr->length];\n        }\n        i = s->method->ssl3_enc->mac(s, md, 0   );\n        if (i < 0 || mac == NULL\n            || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)\n            enc_err = -1;\n        if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + extra + mac_size)\n            enc_err = -1;\n    }\n    if (enc_err < 0) {\n        al = SSL_AD_BAD_RECORD_MAC;\n        SSLerr(SSL_F_SSL3_GET_RECORD,\n               SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);\n        goto f_err;\n    }\n    if (s->expand != NULL) {\n        if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + extra) {\n            al = SSL_AD_RECORD_OVERFLOW;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_COMPRESSED_LENGTH_TOO_LONG);\n            goto f_err;\n        }\n        if (!ssl3_do_uncompress(s)) {\n            al = SSL_AD_DECOMPRESSION_FAILURE;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BAD_DECOMPRESSION);\n            goto f_err;\n        }\n    }\n    if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH + extra) {\n        al = SSL_AD_RECORD_OVERFLOW;\n        SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DATA_LENGTH_TOO_LONG);\n        goto f_err;\n    }\n    rr->off = 0;\n    RECORD_LAYER_reset_packet_length(&s->rlayer);\n    if (rr->length == 0) {\n        empty_record_count++;\n        if (empty_record_count > MAX_EMPTY_RECORDS) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_RECORD_TOO_SMALL);\n            goto f_err;\n        }\n        goto again;\n    }\n    return (1);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\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}']