test/dtlsv1listentest.c:320: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `DTLSv1_listen`.
Showing all 18 steps of the trace


test/dtlsv1listentest.c:308:10: Call
306.   
307.       /* Create an SSL object and set the BIO */
308.       if (!TEST_ptr(ssl = SSL_new(ctx))
                ^
309.               || !TEST_ptr(outbio = BIO_new(BIO_s_mem())))
310.           goto err;

ssl/ssl_lib.c:521:1: Parameter `ctx->sessions->num_items`
  519.   }
  520.   
  521. > SSL *SSL_new(SSL_CTX *ctx)
  522.   {
  523.       SSL *s;

test/dtlsv1listentest.c:320:10: Call
318.   
319.       /* Process the incoming packet */
320.       if (!TEST_int_ge(ret = DTLSv1_listen(ssl, peer), 0))
                ^
321.           goto err;
322.       datalen = BIO_get_mem_data(outbio, &data);

ssl/d1_lib.c:414:1: Parameter `s->session_ctx->sessions->num_items`
  412.   
  413.   #ifndef OPENSSL_NO_SOCK
  414. > int DTLSv1_listen(SSL *s, BIO_ADDR *client)
  415.   {
  416.       int next, n, ret = 0, clearpkt = 0;

ssl/d1_lib.c:434:10: Call
  432.   
  433.       /* Ensure there is no state left over from a previous invocation */
  434.       if (!SSL_clear(s))
                  ^
  435.           return -1;
  436.   

ssl/ssl_lib.c:442:1: Parameter `s->session_ctx->sessions->num_items`
    440.   }
    441.   
    442. > int SSL_clear(SSL *s)
    443.   {
    444.       if (s->method == NULL) {

ssl/ssl_lib.c:449:9: Call
    447.       }
    448.   
    449.       if (ssl_clear_bad_session(s)) {
                   ^
    450.           SSL_SESSION_free(s->session);
    451.           s->session = NULL;

ssl/ssl_sess.c:1049:1: Parameter `s->session_ctx->sessions->num_items`
      1047.   }
      1048.   
      1049. > int ssl_clear_bad_session(SSL *s)
      1050.   {
      1051.       if ((s->session != NULL) &&

ssl/ssl_sess.c:1054:9: Call
      1052.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
      1053.           !(SSL_in_init(s) || SSL_in_before(s))) {
      1054.           SSL_CTX_remove_session(s->session_ctx, s->session);
                      ^
      1055.           return (1);
      1056.       } else

ssl/ssl_sess.c:725:1: Parameter `ctx->sessions->num_items`
        723.   }
        724.   
        725. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
        726.   {
        727.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:727:12: Call
        725.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
        726.   {
        727.       return remove_session_lock(ctx, c, 1);
                          ^
        728.   }
        729.   

ssl/ssl_sess.c:730:1: Parameter `ctx->sessions->num_items`
          728.   }
          729.   
          730. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
          731.   {
          732.       SSL_SESSION *r;

ssl/ssl_sess.c:740:17: Call
          738.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
          739.               ret = 1;
          740.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                                 ^
          741.               SSL_SESSION_list_remove(ctx, c);
          742.           }

ssl/ssl_locl.h:689:1: Parameter `lh->num_items`
            687.   } CLIENTHELLO_MSG;
            688.   
            689. > DEFINE_LHASH_OF(SSL_SESSION);
            690.   /* Needed in ssl_cert.c */
            691.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:689:1: Call
            687.   } CLIENTHELLO_MSG;
            688.   
            689. > DEFINE_LHASH_OF(SSL_SESSION);
            690.   /* Needed in ssl_cert.c */
            691.   DEFINE_LHASH_OF(X509_NAME);

crypto/lhash/lhash.c:103:1: <LHS trace>
101.   }
102.   
103. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
104.   {
105.       unsigned long hash;

crypto/lhash/lhash.c:103:1: Parameter `lh->num_items`
              101.   }
              102.   
              103. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
              104.   {
              105.       unsigned long hash;

crypto/lhash/lhash.c:123:5: Binary operation: ([0, +oo] - 1):unsigned64 by call to `DTLSv1_listen` 
              121.       }
              122.   
              123.       lh->num_items--;
                         ^
              124.       if ((lh->num_nodes > MIN_NODES) &&
              125.           (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))

void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
{
    unsigned long hash;
    OPENSSL_LH_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 dtls_listen_test(int i)\n{\n    SSL_CTX *ctx = NULL;\n    SSL *ssl = NULL;\n    BIO *outbio = NULL;\n    BIO *inbio = NULL;\n    BIO_ADDR *peer = NULL;\n    tests *tp = &testpackets[i];\n    char *data;\n    long datalen;\n    int ret, success = 0;\n    if (!TEST_ptr(ctx = SSL_CTX_new(DTLS_server_method()))\n            || !TEST_ptr(peer = BIO_ADDR_new()))\n        goto err;\n    SSL_CTX_set_cookie_generate_cb(ctx, cookie_gen);\n    SSL_CTX_set_cookie_verify_cb(ctx, cookie_verify);\n    if (!TEST_ptr(ssl = SSL_new(ctx))\n            || !TEST_ptr(outbio = BIO_new(BIO_s_mem())))\n        goto err;\n    SSL_set0_wbio(ssl, outbio);\n    if (!TEST_ptr(inbio = BIO_new_mem_buf((char *)tp->in, tp->inlen)))\n        goto err;\n    BIO_set_mem_eof_return(inbio, -1);\n    SSL_set0_rbio(ssl, inbio);\n    if (!TEST_int_ge(ret = DTLSv1_listen(ssl, peer), 0))\n        goto err;\n    datalen = BIO_get_mem_data(outbio, &data);\n    if (tp->outtype == VERIFY) {\n        if (!TEST_int_eq(ret, 0)\n                || !TEST_mem_eq(data, datalen, verify, sizeof(verify)))\n            goto err;\n    } else if (datalen == 0) {\n        if (!TEST_true((ret == 0 && tp->outtype == DROP)\n                || (ret == 1 && tp->outtype == GOOD)))\n            goto err;\n    } else {\n        TEST_info("Test %d: unexpected data output", i);\n        goto err;\n    }\n    (void)BIO_reset(outbio);\n    inbio = NULL;\n    SSL_set0_rbio(ssl, NULL);\n    success = 1;\n err:\n    SSL_free(ssl);\n    SSL_CTX_free(ctx);\n    BIO_free(inbio);\n    OPENSSL_free(peer);\n    return success;\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 = OPENSSL_zalloc(sizeof(*s));\n    if (s == NULL)\n        goto err;\n    s->lock = CRYPTO_THREAD_lock_new();\n    if (s->lock == NULL) {\n        SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(s);\n        return NULL;\n    }\n    RECORD_LAYER_init(&s->rlayer, s);\n    s->options = ctx->options;\n    s->dane.flags = ctx->dane.flags;\n    s->min_proto_version = ctx->min_proto_version;\n    s->max_proto_version = ctx->max_proto_version;\n    s->mode = ctx->mode;\n    s->max_cert_list = ctx->max_cert_list;\n    s->references = 1;\n    s->max_early_data = ctx->max_early_data;\n    s->cert = ssl_cert_dup(ctx->cert);\n    if (s->cert == NULL)\n        goto err;\n    RECORD_LAYER_set_read_ahead(&s->rlayer, 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    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 == NULL)\n        goto err;\n    X509_VERIFY_PARAM_inherit(s->param, ctx->param);\n    s->quiet_shutdown = ctx->quiet_shutdown;\n    s->max_send_fragment = ctx->max_send_fragment;\n    s->split_send_fragment = ctx->split_send_fragment;\n    s->max_pipelines = ctx->max_pipelines;\n    if (s->max_pipelines > 1)\n        RECORD_LAYER_set_read_ahead(&s->rlayer, 1);\n    if (ctx->default_read_buf_len > 0)\n        SSL_set_default_read_buffer_len(s, ctx->default_read_buf_len);\n    SSL_CTX_up_ref(ctx);\n    s->ctx = ctx;\n    s->ext.debug_cb = 0;\n    s->ext.debug_arg = NULL;\n    s->ext.ticket_expected = 0;\n    s->ext.status_type = ctx->ext.status_type;\n    s->ext.status_expected = 0;\n    s->ext.ocsp.ids = NULL;\n    s->ext.ocsp.exts = NULL;\n    s->ext.ocsp.resp = NULL;\n    s->ext.ocsp.resp_len = 0;\n    SSL_CTX_up_ref(ctx);\n    s->session_ctx = ctx;\n#ifndef OPENSSL_NO_EC\n    if (ctx->ext.ecpointformats) {\n        s->ext.ecpointformats =\n            OPENSSL_memdup(ctx->ext.ecpointformats,\n                           ctx->ext.ecpointformats_len);\n        if (!s->ext.ecpointformats)\n            goto err;\n        s->ext.ecpointformats_len =\n            ctx->ext.ecpointformats_len;\n    }\n    if (ctx->ext.supportedgroups) {\n        s->ext.supportedgroups =\n            OPENSSL_memdup(ctx->ext.supportedgroups,\n                           ctx->ext.supportedgroups_len);\n        if (!s->ext.supportedgroups)\n            goto err;\n        s->ext.supportedgroups_len = ctx->ext.supportedgroups_len;\n    }\n#endif\n#ifndef OPENSSL_NO_NEXTPROTONEG\n    s->ext.npn = NULL;\n#endif\n    if (s->ctx->ext.alpn) {\n        s->ext.alpn = OPENSSL_malloc(s->ctx->ext.alpn_len);\n        if (s->ext.alpn == NULL)\n            goto err;\n        memcpy(s->ext.alpn, s->ctx->ext.alpn, s->ctx->ext.alpn_len);\n        s->ext.alpn_len = s->ctx->ext.alpn_len;\n    }\n    s->verified_chain = NULL;\n    s->verify_result = X509_V_OK;\n    s->default_passwd_callback = ctx->default_passwd_callback;\n    s->default_passwd_callback_userdata = ctx->default_passwd_callback_userdata;\n    s->method = ctx->method;\n    s->key_update = SSL_KEY_UPDATE_NONE;\n    if (!s->method->ssl_new(s))\n        goto err;\n    s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;\n    if (!SSL_clear(s))\n        goto err;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data))\n        goto err;\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    s->job = NULL;\n#ifndef OPENSSL_NO_CT\n    if (!SSL_set_ct_validation_callback(s, ctx->ct_validation_callback,\n                                        ctx->ct_validation_callback_arg))\n        goto err;\n#endif\n    return s;\n err:\n    SSL_free(s);\n    SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n    return NULL;\n}', 'int DTLSv1_listen(SSL *s, BIO_ADDR *client)\n{\n    int next, n, ret = 0, clearpkt = 0;\n    unsigned char cookie[DTLS1_COOKIE_LENGTH];\n    unsigned char seq[SEQ_NUM_SIZE];\n    const unsigned char *data;\n    unsigned char *buf;\n    size_t fragoff, fraglen, msglen;\n    unsigned int rectype, versmajor, msgseq, msgtype, clientvers, cookielen;\n    BIO *rbio, *wbio;\n    BUF_MEM *bufm;\n    BIO_ADDR *tmpclient = NULL;\n    PACKET pkt, msgpkt, msgpayload, session, cookiepkt;\n    if (s->handshake_func == NULL) {\n        SSL_set_accept_state(s);\n    }\n    if (!SSL_clear(s))\n        return -1;\n    ERR_clear_error();\n    rbio = SSL_get_rbio(s);\n    wbio = SSL_get_wbio(s);\n    if (!rbio || !wbio) {\n        SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_BIO_NOT_SET);\n        return -1;\n    }\n    BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_PEEK_MODE, 1, NULL);\n    if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00)) {\n        SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_UNSUPPORTED_SSL_VERSION);\n        return -1;\n    }\n    if (s->init_buf == NULL) {\n        if ((bufm = BUF_MEM_new()) == NULL) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_MALLOC_FAILURE);\n            return -1;\n        }\n        if (!BUF_MEM_grow(bufm, SSL3_RT_MAX_PLAIN_LENGTH)) {\n            BUF_MEM_free(bufm);\n            SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_MALLOC_FAILURE);\n            return -1;\n        }\n        s->init_buf = bufm;\n    }\n    buf = (unsigned char *)s->init_buf->data;\n    do {\n        clear_sys_error();\n        n = BIO_read(rbio, buf, SSL3_RT_MAX_PLAIN_LENGTH);\n        if (n <= 0) {\n            if (BIO_should_retry(rbio)) {\n                goto end;\n            }\n            return -1;\n        }\n        clearpkt = 1;\n        if (!PACKET_buf_init(&pkt, buf, n)) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_INTERNAL_ERROR);\n            return -1;\n        }\n        if (n < DTLS1_RT_HEADER_LENGTH) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_RECORD_TOO_SMALL);\n            goto end;\n        }\n        if (s->msg_callback)\n            s->msg_callback(0, 0, SSL3_RT_HEADER, buf,\n                            DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);\n        if (!PACKET_get_1(&pkt, &rectype)\n            || !PACKET_get_1(&pkt, &versmajor)) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_LENGTH_MISMATCH);\n            goto end;\n        }\n        if (rectype != SSL3_RT_HANDSHAKE) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_UNEXPECTED_MESSAGE);\n            goto end;\n        }\n        if (versmajor != DTLS1_VERSION_MAJOR) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_BAD_PROTOCOL_VERSION_NUMBER);\n            goto end;\n        }\n        if (!PACKET_forward(&pkt, 1)\n            || !PACKET_copy_bytes(&pkt, seq, SEQ_NUM_SIZE)\n            || !PACKET_get_length_prefixed_2(&pkt, &msgpkt)) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_LENGTH_MISMATCH);\n            goto end;\n        }\n        if (seq[0] != 0 || seq[1] != 0) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_UNEXPECTED_MESSAGE);\n            goto end;\n        }\n        data = PACKET_data(&msgpkt);\n        if (!PACKET_get_1(&msgpkt, &msgtype)\n            || !PACKET_get_net_3_len(&msgpkt, &msglen)\n            || !PACKET_get_net_2(&msgpkt, &msgseq)\n            || !PACKET_get_net_3_len(&msgpkt, &fragoff)\n            || !PACKET_get_net_3_len(&msgpkt, &fraglen)\n            || !PACKET_get_sub_packet(&msgpkt, &msgpayload, fraglen)\n            || PACKET_remaining(&msgpkt) != 0) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_LENGTH_MISMATCH);\n            goto end;\n        }\n        if (msgtype != SSL3_MT_CLIENT_HELLO) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_UNEXPECTED_MESSAGE);\n            goto end;\n        }\n        if (msgseq > 2) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_INVALID_SEQUENCE_NUMBER);\n            goto end;\n        }\n        if (fragoff != 0 || fraglen > msglen) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_FRAGMENTED_CLIENT_HELLO);\n            goto end;\n        }\n        if (s->msg_callback)\n            s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, data,\n                            fraglen + DTLS1_HM_HEADER_LENGTH, s,\n                            s->msg_callback_arg);\n        if (!PACKET_get_net_2(&msgpayload, &clientvers)) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_LENGTH_MISMATCH);\n            goto end;\n        }\n        if (DTLS_VERSION_LT(clientvers, (unsigned int)s->method->version) &&\n            s->method->version != DTLS_ANY_VERSION) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_WRONG_VERSION_NUMBER);\n            goto end;\n        }\n        if (!PACKET_forward(&msgpayload, SSL3_RANDOM_SIZE)\n            || !PACKET_get_length_prefixed_1(&msgpayload, &session)\n            || !PACKET_get_length_prefixed_1(&msgpayload, &cookiepkt)) {\n            SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_LENGTH_MISMATCH);\n            goto end;\n        }\n        if (PACKET_remaining(&cookiepkt) == 0) {\n            next = LISTEN_SEND_VERIFY_REQUEST;\n        } else {\n            if (s->ctx->app_verify_cookie_cb == NULL) {\n                SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_NO_VERIFY_COOKIE_CALLBACK);\n                return -1;\n            }\n            if (s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookiepkt),\n                    (unsigned int)PACKET_remaining(&cookiepkt)) == 0) {\n                next = LISTEN_SEND_VERIFY_REQUEST;\n            } else {\n                next = LISTEN_SUCCESS;\n            }\n        }\n        if (next == LISTEN_SEND_VERIFY_REQUEST) {\n            WPACKET wpkt;\n            unsigned int version;\n            size_t wreclen;\n            BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_PEEK_MODE, 0, NULL);\n            BIO_read(rbio, buf, SSL3_RT_MAX_PLAIN_LENGTH);\n            BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_PEEK_MODE, 1, NULL);\n            if (s->ctx->app_gen_cookie_cb == NULL ||\n                s->ctx->app_gen_cookie_cb(s, cookie, &cookielen) == 0 ||\n                cookielen > 255) {\n                SSLerr(SSL_F_DTLSV1_LISTEN, SSL_R_COOKIE_GEN_CALLBACK_FAILURE);\n                return -1;\n            }\n            version = (s->method->version == DTLS_ANY_VERSION) ? DTLS1_VERSION\n                                                               : s->version;\n            if (!WPACKET_init(&wpkt, s->init_buf)\n                    || !WPACKET_put_bytes_u8(&wpkt, SSL3_RT_HANDSHAKE)\n                    || !WPACKET_put_bytes_u16(&wpkt, version)\n                    || !WPACKET_memcpy(&wpkt, seq, SEQ_NUM_SIZE)\n                    || !WPACKET_start_sub_packet_u16(&wpkt)\n                    || !WPACKET_put_bytes_u8(&wpkt,\n                                             DTLS1_MT_HELLO_VERIFY_REQUEST)\n                    || !WPACKET_put_bytes_u24(&wpkt, 0)\n                    || !WPACKET_put_bytes_u16(&wpkt, 0)\n                    || !WPACKET_put_bytes_u24(&wpkt, 0)\n                    || !WPACKET_start_sub_packet_u24(&wpkt)\n                    || !dtls_raw_hello_verify_request(&wpkt, cookie, cookielen)\n                    || !WPACKET_close(&wpkt)\n                    || !WPACKET_close(&wpkt)\n                    || !WPACKET_get_total_written(&wpkt, &wreclen)\n                    || !WPACKET_finish(&wpkt)) {\n                SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_INTERNAL_ERROR);\n                WPACKET_cleanup(&wpkt);\n                return -1;\n            }\n            memcpy(&buf[DTLS1_RT_HEADER_LENGTH + 1],\n                   &buf[DTLS1_RT_HEADER_LENGTH + DTLS1_HM_HEADER_LENGTH - 3],\n                   3);\n            if (s->msg_callback)\n                s->msg_callback(1, 0, SSL3_RT_HEADER, buf,\n                                DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);\n            if ((tmpclient = BIO_ADDR_new()) == NULL) {\n                SSLerr(SSL_F_DTLSV1_LISTEN, ERR_R_MALLOC_FAILURE);\n                goto end;\n            }\n            if (BIO_dgram_get_peer(rbio, tmpclient) > 0) {\n                (void)BIO_dgram_set_peer(wbio, tmpclient);\n            }\n            BIO_ADDR_free(tmpclient);\n            tmpclient = NULL;\n            if (BIO_write(wbio, buf, wreclen) < (int)wreclen) {\n                if (BIO_should_retry(wbio)) {\n                    goto end;\n                }\n                return -1;\n            }\n            if (BIO_flush(wbio) <= 0) {\n                if (BIO_should_retry(wbio)) {\n                    goto end;\n                }\n                return -1;\n            }\n        }\n    } while (next != LISTEN_SUCCESS);\n    s->d1->handshake_read_seq = 1;\n    s->d1->handshake_write_seq = 1;\n    s->d1->next_handshake_write_seq = 1;\n    DTLS_RECORD_LAYER_set_write_sequence(&s->rlayer, seq);\n    SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE);\n    ossl_statem_set_hello_verify_done(s);\n    if (BIO_dgram_get_peer(rbio, client) <= 0)\n        BIO_ADDR_clear(client);\n    ret = 1;\n    clearpkt = 0;\n end:\n    BIO_ADDR_free(tmpclient);\n    BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_PEEK_MODE, 0, NULL);\n    if (clearpkt) {\n        BIO_read(rbio, buf, SSL3_RT_MAX_PLAIN_LENGTH);\n    }\n    return ret;\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 (s->renegotiate) {\n        SSLerr(SSL_F_SSL_CLEAR, ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n    ossl_statem_clear(s);\n    s->version = s->method->version;\n    s->client_version = s->version;\n    s->rwstate = SSL_NOTHING;\n    BUF_MEM_free(s->init_buf);\n    s->init_buf = NULL;\n    clear_ciphers(s);\n    s->first_packet = 0;\n    s->key_update = SSL_KEY_UPDATE_NONE;\n    s->dane.mdpth = -1;\n    s->dane.pdpth = -1;\n    X509_free(s->dane.mcert);\n    s->dane.mcert = NULL;\n    s->dane.mtlsa = NULL;\n    X509_VERIFY_PARAM_move_peername(s->param, NULL);\n    if (!ossl_statem_get_in_handshake(s) && (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        s->method->ssl_clear(s);\n    RECORD_LAYER_clear(&s->rlayer);\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->session_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_THREAD_write_lock(ctx->lock);\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        c->not_resumable = 1;\n        if (lck)\n            CRYPTO_THREAD_unlock(ctx->lock);\n        if (ret)\n            SSL_SESSION_free(r);\n        if (ctx->remove_session_cb != NULL)\n            ctx->remove_session_cb(ctx, c);\n    } else\n        ret = 0;\n    return (ret);\n}', 'DEFINE_LHASH_OF(SSL_SESSION)', 'void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_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}']