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


test/sslapitest.c:3361:10: Call
3359.       size_t readbytes, written;
3360.   
3361.       if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
                 ^
3362.                                           &serverssl, NULL, idx)))
3363.           goto end;

test/sslapitest.c:2386:1: Parameter `(*serverssl)->session_ctx->sessions->num_items`
  2384.    * error.
  2385.    */
  2386. > static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,
  2387.                                   SSL **serverssl, SSL_SESSION **sess, int idx)
  2388.   {

test/sslapitest.c:2464:5: Call
  2462.       SSL_shutdown(*clientssl);
  2463.       SSL_shutdown(*serverssl);
  2464.       SSL_free(*serverssl);
              ^
  2465.       SSL_free(*clientssl);
  2466.       *serverssl = *clientssl = NULL;

ssl/ssl_lib.c:1138:1: Parameter `s->session_ctx->sessions->num_items`
    1136.   }
    1137.   
    1138. > void SSL_free(SSL *s)
    1139.   {
    1140.       int i;

ssl/ssl_lib.c:1173:9: Call
    1171.       /* Make the next call work :-) */
    1172.       if (s->session != NULL) {
    1173.           ssl_clear_bad_session(s);
                    ^
    1174.           SSL_SESSION_free(s->session);
    1175.       }

ssl/ssl_sess.c:1124:1: Parameter `s->session_ctx->sessions->num_items`
      1122.   }
      1123.   
      1124. > int ssl_clear_bad_session(SSL *s)
      1125.   {
      1126.       if ((s->session != NULL) &&

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

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

ssl/ssl_sess.c:744:12: Call
        742.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
        743.   {
        744.       return remove_session_lock(ctx, c, 1);
                          ^
        745.   }
        746.   

ssl/ssl_sess.c:747:1: Parameter `ctx->sessions->num_items`
          745.   }
          746.   
          747. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
          748.   {
          749.       SSL_SESSION *r;

ssl/ssl_sess.c:757:17: Call
          755.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) != NULL) {
          756.               ret = 1;
          757.               r = lh_SSL_SESSION_delete(ctx->sessions, r);
                                 ^
          758.               SSL_SESSION_list_remove(ctx, r);
          759.           }

ssl/ssl_locl.h:735:1: Parameter `lh->num_items`
            733.   } TLSEXT_INDEX;
            734.   
            735. > DEFINE_LHASH_OF(SSL_SESSION);
            736.   /* Needed in ssl_cert.c */
            737.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:735:1: Call
            733.   } TLSEXT_INDEX;
            734.   
            735. > DEFINE_LHASH_OF(SSL_SESSION);
            736.   /* Needed in ssl_cert.c */
            737.   DEFINE_LHASH_OF(X509_NAME);

crypto/lhash/lhash.c:137:1: <LHS trace>
135.   }
136.   
137. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
138.   {
139.       unsigned long hash;

crypto/lhash/lhash.c:137:1: Parameter `lh->num_items`
              135.   }
              136.   
              137. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
              138.   {
              139.       unsigned long hash;

crypto/lhash/lhash.c:157:5: Binary operation: ([0, +oo] - 1):unsigned64 by call to `setupearly_data_test` 
              155.       }
              156.   
              157.       lh->num_items--;
                         ^
              158.       if ((lh->num_nodes > MIN_NODES) &&
              159.           (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_early_data_tls1_2(int idx)\n{\n    SSL_CTX *cctx = NULL, *sctx = NULL;\n    SSL *clientssl = NULL, *serverssl = NULL;\n    int testresult = 0;\n    unsigned char buf[20];\n    size_t readbytes, written;\n    if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,\n                                        &serverssl, NULL, idx)))\n        goto end;\n    SSL_set_max_proto_version(clientssl, TLS1_2_VERSION);\n    SSL_set_connect_state(clientssl);\n    if (!TEST_false(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written)))\n        goto end;\n    if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                         &readbytes),\n                     SSL_READ_EARLY_DATA_ERROR))\n        goto end;\n    if (!TEST_false(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written))\n            || !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                                &readbytes),\n                            SSL_READ_EARLY_DATA_FINISH)\n            || !TEST_size_t_eq(readbytes, 0)\n            || !TEST_int_eq(SSL_get_early_data_status(serverssl),\n                            SSL_EARLY_DATA_NOT_SENT))\n        goto end;\n    if (!TEST_true(SSL_write_ex(clientssl, MSG1, strlen(MSG1), &written))\n            || !TEST_size_t_eq(written, strlen(MSG1))\n            || !TEST_int_eq(SSL_get_early_data_status(clientssl),\n                            SSL_EARLY_DATA_NOT_SENT)\n            || !TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))\n            || !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1))\n            || !TEST_true(SSL_write_ex(serverssl, MSG2, strlen(MSG2), &written))\n            || !TEST_size_t_eq(written, strlen(MSG2))\n            || !SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)\n            || !TEST_mem_eq(buf, readbytes, MSG2, strlen(MSG2)))\n        goto end;\n    testresult = 1;\n end:\n    SSL_SESSION_free(clientpsk);\n    SSL_SESSION_free(serverpsk);\n    clientpsk = serverpsk = NULL;\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    SSL_CTX_free(sctx);\n    SSL_CTX_free(cctx);\n    return testresult;\n}', 'static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,\n                                SSL **serverssl, SSL_SESSION **sess, int idx)\n{\n    if (*sctx == NULL\n            && !TEST_true(create_ssl_ctx_pair(TLS_server_method(),\n                                              TLS_client_method(),\n                                              TLS1_VERSION, 0,\n                                              sctx, cctx, cert, privkey)))\n        return 0;\n    if (!TEST_true(SSL_CTX_set_max_early_data(*sctx, SSL3_RT_MAX_PLAIN_LENGTH)))\n        return 0;\n    if (idx == 1) {\n        SSL_CTX_set_read_ahead(*cctx, 1);\n        SSL_CTX_set_read_ahead(*sctx, 1);\n    } else if (idx == 2) {\n        SSL_CTX_set_psk_use_session_callback(*cctx, use_session_cb);\n        SSL_CTX_set_psk_find_session_callback(*sctx, find_session_cb);\n        use_session_cb_cnt = 0;\n        find_session_cb_cnt = 0;\n        srvid = pskid;\n    }\n    if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl, clientssl,\n                                      NULL, NULL)))\n        return 0;\n    if (idx == 1\n            && !TEST_true(SSL_set_tlsext_host_name(*clientssl, "localhost")))\n        return 0;\n    if (idx == 2) {\n        clientpsk = create_a_psk(*clientssl);\n        if (!TEST_ptr(clientpsk)\n                || !TEST_true(SSL_SESSION_set_max_early_data(clientpsk,\n                                                             0x100))\n                || !TEST_true(SSL_SESSION_up_ref(clientpsk))) {\n            SSL_SESSION_free(clientpsk);\n            clientpsk = NULL;\n            return 0;\n        }\n        serverpsk = clientpsk;\n        if (sess != NULL) {\n            if (!TEST_true(SSL_SESSION_up_ref(clientpsk))) {\n                SSL_SESSION_free(clientpsk);\n                SSL_SESSION_free(serverpsk);\n                clientpsk = serverpsk = NULL;\n                return 0;\n            }\n            *sess = clientpsk;\n        }\n        return 1;\n    }\n    if (sess == NULL)\n        return 1;\n    if (!TEST_true(create_ssl_connection(*serverssl, *clientssl,\n                                         SSL_ERROR_NONE)))\n        return 0;\n    *sess = SSL_get1_session(*clientssl);\n    SSL_shutdown(*clientssl);\n    SSL_shutdown(*serverssl);\n    SSL_free(*serverssl);\n    SSL_free(*clientssl);\n    *serverssl = *clientssl = NULL;\n    if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl,\n                                      clientssl, NULL, NULL))\n            || !TEST_true(SSL_set_session(*clientssl, *sess)))\n        return 0;\n    return 1;\n}', 'void SSL_free(SSL *s)\n{\n    int i;\n    if (s == NULL)\n        return;\n    CRYPTO_DOWN_REF(&s->references, &i, s->lock);\n    REF_PRINT_COUNT("SSL", s);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    X509_VERIFY_PARAM_free(s->param);\n    dane_final(&s->dane);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n    RECORD_LAYER_release(&s->rlayer);\n    ssl_free_wbio_buffer(s);\n    BIO_free_all(s->wbio);\n    s->wbio = NULL;\n    BIO_free_all(s->rbio);\n    s->rbio = NULL;\n    BUF_MEM_free(s->init_buf);\n    sk_SSL_CIPHER_free(s->cipher_list);\n    sk_SSL_CIPHER_free(s->cipher_list_by_id);\n    sk_SSL_CIPHER_free(s->tls13_ciphersuites);\n    if (s->session != NULL) {\n        ssl_clear_bad_session(s);\n        SSL_SESSION_free(s->session);\n    }\n    SSL_SESSION_free(s->psksession);\n    OPENSSL_free(s->psksession_id);\n    clear_ciphers(s);\n    ssl_cert_free(s->cert);\n    OPENSSL_free(s->ext.hostname);\n    SSL_CTX_free(s->session_ctx);\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(s->ext.ecpointformats);\n    OPENSSL_free(s->ext.supportedgroups);\n#endif\n    sk_X509_EXTENSION_pop_free(s->ext.ocsp.exts, X509_EXTENSION_free);\n#ifndef OPENSSL_NO_OCSP\n    sk_OCSP_RESPID_pop_free(s->ext.ocsp.ids, OCSP_RESPID_free);\n#endif\n#ifndef OPENSSL_NO_CT\n    SCT_LIST_free(s->scts);\n    OPENSSL_free(s->ext.scts);\n#endif\n    OPENSSL_free(s->ext.ocsp.resp);\n    OPENSSL_free(s->ext.alpn);\n    OPENSSL_free(s->ext.tls13_cookie);\n    OPENSSL_free(s->clienthello);\n    OPENSSL_free(s->pha_context);\n    EVP_MD_CTX_free(s->pha_dgst);\n    sk_X509_NAME_pop_free(s->ca_names, X509_NAME_free);\n    sk_X509_NAME_pop_free(s->client_ca_names, X509_NAME_free);\n    sk_X509_pop_free(s->verified_chain, X509_free);\n    if (s->method != NULL)\n        s->method->ssl_free(s);\n    SSL_CTX_free(s->ctx);\n    ASYNC_WAIT_CTX_free(s->waitctx);\n#if !defined(OPENSSL_NO_NEXTPROTONEG)\n    OPENSSL_free(s->ext.npn);\n#endif\n#ifndef OPENSSL_NO_SRTP\n    sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles);\n#endif\n    CRYPTO_THREAD_lock_free(s->lock);\n    OPENSSL_free(s);\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)) != NULL) {\n            ret = 1;\n            r = lh_SSL_SESSION_delete(ctx->sessions, r);\n            SSL_SESSION_list_remove(ctx, r);\n        }\n        c->not_resumable = 1;\n        if (lck)\n            CRYPTO_THREAD_unlock(ctx->lock);\n        if (ctx->remove_session_cb != NULL)\n            ctx->remove_session_cb(ctx, c);\n        if (ret)\n            SSL_SESSION_free(r);\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}']