test/sslapitest.c:2749: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `SSL_stateless`.
Showing all 19 steps of the trace


test/sslapitest.c:2740:10: Call
2738.       SSL_CTX_clear_options(cctx, SSL_OP_ENABLE_MIDDLEBOX_COMPAT);
2739.   
2740.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
                 ^
2741.                                         NULL, NULL))
2742.                  /* Send the first ClientHello */

test/ssltestlib.c:559:15: Call
  557.       if (*sssl != NULL)
  558.           serverssl = *sssl;
  559.       else if (!TEST_ptr(serverssl = SSL_new(serverctx)))
                       ^
  560.           goto error;
  561.       if (*cssl != NULL)

ssl/ssl_lib.c:666:1: Parameter `ctx->sessions->num_items`
    664.   }
    665.   
    666. > SSL *SSL_new(SSL_CTX *ctx)
    667.   {
    668.       SSL *s;

test/sslapitest.c:2749:17: Call
2747.                   * set up
2748.                   */
2749.               || !TEST_int_eq(SSL_stateless(serverssl), -1))
                        ^
2750.           goto end;
2751.   

ssl/ssl_lib.c:5338:1: Parameter `s->session_ctx->sessions->num_items`
  5336.   }
  5337.   
  5338. > int SSL_stateless(SSL *s)
  5339.   {
  5340.       int ret;

ssl/ssl_lib.c:5343:10: Call
  5341.   
  5342.       /* Ensure there is no state left over from a previous invocation */
  5343.       if (!SSL_clear(s))
                   ^
  5344.           return 0;
  5345.   

ssl/ssl_lib.c:577:1: Parameter `s->session_ctx->sessions->num_items`
    575.   }
    576.   
    577. > int SSL_clear(SSL *s)
    578.   {
    579.       if (s->method == NULL) {

ssl/ssl_lib.c:584:9: Call
    582.       }
    583.   
    584.       if (ssl_clear_bad_session(s)) {
                   ^
    585.           SSL_SESSION_free(s->session);
    586.           s->session = NULL;

ssl/ssl_sess.c:1120:1: Parameter `s->session_ctx->sessions->num_items`
      1118.   }
      1119.   
      1120. > int ssl_clear_bad_session(SSL *s)
      1121.   {
      1122.       if ((s->session != NULL) &&

ssl/ssl_sess.c:1125:9: Call
      1123.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
      1124.           !(SSL_in_init(s) || SSL_in_before(s))) {
      1125.           SSL_CTX_remove_session(s->session_ctx, s->session);
                      ^
      1126.           return 1;
      1127.       } else

ssl/ssl_sess.c:737:1: Parameter `ctx->sessions->num_items`
        735.   }
        736.   
        737. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
        738.   {
        739.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:739:12: Call
        737.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
        738.   {
        739.       return remove_session_lock(ctx, c, 1);
                          ^
        740.   }
        741.   

ssl/ssl_sess.c:742:1: Parameter `ctx->sessions->num_items`
          740.   }
          741.   
          742. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
          743.   {
          744.       SSL_SESSION *r;

ssl/ssl_sess.c:752:17: Call
          750.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
          751.               ret = 1;
          752.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                                 ^
          753.               SSL_SESSION_list_remove(ctx, c);
          754.           }

ssl/ssl_locl.h:730:1: Parameter `lh->num_items`
            728.   } TLSEXT_INDEX;
            729.   
            730. > DEFINE_LHASH_OF(SSL_SESSION);
            731.   /* Needed in ssl_cert.c */
            732.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:730:1: Call
            728.   } TLSEXT_INDEX;
            729.   
            730. > DEFINE_LHASH_OF(SSL_SESSION);
            731.   /* Needed in ssl_cert.c */
            732.   DEFINE_LHASH_OF(X509_NAME);

crypto/lhash/lhash.c:119:1: <LHS trace>
117.   }
118.   
119. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
120.   {
121.       unsigned long hash;

crypto/lhash/lhash.c:119:1: Parameter `lh->num_items`
              117.   }
              118.   
              119. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
              120.   {
              121.       unsigned long hash;

crypto/lhash/lhash.c:139:5: Binary operation: ([0, +oo] - 1):unsigned64 by call to `SSL_stateless` 
              137.       }
              138.   
              139.       lh->num_items--;
                         ^
              140.       if ((lh->num_nodes > MIN_NODES) &&
              141.           (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 test_stateless(void)\n{\n    SSL_CTX *sctx = NULL, *cctx = NULL;\n    SSL *serverssl = NULL, *clientssl = NULL;\n    int testresult = 0;\n    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),\n                                       TLS_client_method(), &sctx,\n                                       &cctx, cert, privkey)))\n        goto end;\n    SSL_CTX_clear_options(cctx, SSL_OP_ENABLE_MIDDLEBOX_COMPAT);\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,\n                                      NULL, NULL))\n            || !TEST_false(create_ssl_connection(serverssl, clientssl,\n                                                 SSL_ERROR_WANT_READ))\n            || !TEST_int_eq(SSL_stateless(serverssl), -1))\n        goto end;\n    SSL_free(clientssl);\n    clientssl = NULL;\n    SSL_CTX_set_cookie_generate_cb(sctx, generate_cookie_callback);\n    SSL_CTX_set_cookie_verify_cb(sctx, verify_cookie_callback);\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,\n                                             NULL, NULL))\n            || !TEST_false(create_ssl_connection(serverssl, clientssl,\n                                                SSL_ERROR_WANT_READ))\n            || !TEST_int_eq(SSL_stateless(serverssl), 0))\n        goto end;\n    SSL_free(clientssl);\n    clientssl = NULL;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,\n                                             NULL, NULL))\n            || !TEST_false(create_ssl_connection(serverssl, clientssl,\n                                                SSL_ERROR_WANT_READ))\n            || !TEST_int_eq(SSL_stateless(serverssl), 0)\n            || !TEST_false(create_ssl_connection(serverssl, clientssl,\n                                                SSL_ERROR_WANT_READ))\n            || !TEST_int_eq(SSL_stateless(serverssl), 1)\n            || !TEST_true(create_ssl_connection(serverssl, clientssl,\n                                                SSL_ERROR_NONE)))\n        goto end;\n    shutdown_ssl_connection(serverssl, clientssl);\n    serverssl = clientssl = NULL;\n    testresult = 1;\n end:\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    SSL_CTX_free(sctx);\n    SSL_CTX_free(cctx);\n    return testresult;\n}', 'int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,\n                          SSL **cssl, BIO *s_to_c_fbio, BIO *c_to_s_fbio)\n{\n    SSL *serverssl = NULL, *clientssl = NULL;\n    BIO *s_to_c_bio = NULL, *c_to_s_bio = NULL;\n    if (*sssl != NULL)\n        serverssl = *sssl;\n    else if (!TEST_ptr(serverssl = SSL_new(serverctx)))\n        goto error;\n    if (*cssl != NULL)\n        clientssl = *cssl;\n    else if (!TEST_ptr(clientssl = SSL_new(clientctx)))\n        goto error;\n    if (SSL_is_dtls(clientssl)) {\n        if (!TEST_ptr(s_to_c_bio = BIO_new(bio_s_mempacket_test()))\n                || !TEST_ptr(c_to_s_bio = BIO_new(bio_s_mempacket_test())))\n            goto error;\n    } else {\n        if (!TEST_ptr(s_to_c_bio = BIO_new(BIO_s_mem()))\n                || !TEST_ptr(c_to_s_bio = BIO_new(BIO_s_mem())))\n            goto error;\n    }\n    if (s_to_c_fbio != NULL\n            && !TEST_ptr(s_to_c_bio = BIO_push(s_to_c_fbio, s_to_c_bio)))\n        goto error;\n    if (c_to_s_fbio != NULL\n            && !TEST_ptr(c_to_s_bio = BIO_push(c_to_s_fbio, c_to_s_bio)))\n        goto error;\n    BIO_set_mem_eof_return(s_to_c_bio, -1);\n    BIO_set_mem_eof_return(c_to_s_bio, -1);\n    SSL_set_bio(serverssl, c_to_s_bio, s_to_c_bio);\n    BIO_up_ref(s_to_c_bio);\n    BIO_up_ref(c_to_s_bio);\n    SSL_set_bio(clientssl, s_to_c_bio, c_to_s_bio);\n    *sssl = serverssl;\n    *cssl = clientssl;\n    return 1;\n error:\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    BIO_free(s_to_c_bio);\n    BIO_free(c_to_s_bio);\n    BIO_free(s_to_c_fbio);\n    BIO_free(c_to_s_fbio);\n    return 0;\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->references = 1;\n    s->lock = CRYPTO_THREAD_lock_new();\n    if (s->lock == NULL) {\n        OPENSSL_free(s);\n        s = NULL;\n        goto err;\n    }\n    if (RAND_get_rand_method() == RAND_OpenSSL()) {\n        s->drbg =\n            RAND_DRBG_new(RAND_DRBG_NID, 0, RAND_DRBG_get0_public());\n        if (s->drbg == NULL\n            || RAND_DRBG_instantiate(s->drbg,\n                                     (const unsigned char *) SSL_version_str,\n                                     sizeof(SSL_version_str) - 1) == 0)\n            goto err;\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->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->record_padding_cb = ctx->record_padding_cb;\n    s->record_padding_arg = ctx->record_padding_arg;\n    s->block_padding = ctx->block_padding;\n    s->sid_ctx_length = ctx->sid_ctx_length;\n    if (!ossl_assert(s->sid_ctx_length <= sizeof(s->sid_ctx)))\n        goto err;\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->ext.max_fragment_len_mode = ctx->ext.max_fragment_len_mode;\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                                * sizeof(*ctx->ext.supportedgroups));\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->psk_find_session_cb = ctx->psk_find_session_cb;\n    s->psk_use_session_cb = ctx->psk_use_session_cb;\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 SSL_stateless(SSL *s)\n{\n    int ret;\n    if (!SSL_clear(s))\n        return 0;\n    ERR_clear_error();\n    s->s3->flags |= TLS1_FLAGS_STATELESS;\n    ret = SSL_accept(s);\n    s->s3->flags &= ~TLS1_FLAGS_STATELESS;\n    if (ret > 0 && s->ext.cookieok)\n        return 1;\n    if (s->hello_retry_request == SSL_HRR_PENDING && !ossl_statem_in_error(s))\n        return 0;\n    return -1;\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    SSL_SESSION_free(s->psksession);\n    s->psksession = NULL;\n    OPENSSL_free(s->psksession_id);\n    s->psksession_id = NULL;\n    s->psksession_id_len = 0;\n    s->hello_retry_request = 0;\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    EVP_MD_CTX_free(s->pha_dgst);\n    s->pha_dgst = NULL;\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 (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        if (!s->method->ssl_clear(s))\n            return 0;\n    }\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}']