test/recordlentest.c:140: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `SSL_accept`.
Showing all 21 steps of the trace


test/recordlentest.c:121:10: Call
119.       }
120.   
121.       if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
                ^
122.           printf("Unable to create SSL objects\n");
123.           goto end;

test/ssltestlib.c:579:21: Call
  577.   
  578.       if (*sssl == NULL)
  579.           serverssl = SSL_new(serverctx);
                             ^
  580.       else
  581.           serverssl = *sssl;

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

test/recordlentest.c:140:13: Call
138.           }
139.   
140.           if (SSL_accept(serverssl) > 0) {
                   ^
141.               printf("Unexpected success reading plaintext record\n");
142.               goto end;

ssl/ssl_lib.c:1460:1: Parameter `s->session_ctx->sessions->num_items`
  1458.   }
  1459.   
  1460. > int SSL_accept(SSL *s)
  1461.   {
  1462.       if (s->handshake_func == NULL) {

ssl/ssl_lib.c:1467:12: Call
  1465.       }
  1466.   
  1467.       return SSL_do_handshake(s);
                     ^
  1468.   }
  1469.   

ssl/ssl_lib.c:3246:1: Parameter `s->session_ctx->sessions->num_items`
    3244.   }
    3245.   
    3246. > int SSL_do_handshake(SSL *s)
    3247.   {
    3248.       int ret = 1;

ssl/ssl_lib.c:3258:17: Call
    3256.           int edfin;
    3257.   
    3258.           edfin = ssl_write_early_finish(s);
                            ^
    3259.           if (edfin <= 0)
    3260.               return edfin;

ssl/ssl_lib.c:1866:1: Parameter `s->session_ctx->sessions->num_items`
      1864.   }
      1865.   
      1866. > static int ssl_write_early_finish(SSL *s)
      1867.   {
      1868.       int ret;

ssl/ssl_lib.c:1876:11: Call
      1874.   
      1875.       s->early_data_state = SSL_EARLY_DATA_WRITING;
      1876.       ret = ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_END_OF_EARLY_DATA);
                        ^
      1877.       if (ret <= 0) {
      1878.           s->early_data_state = SSL_EARLY_DATA_WRITE_RETRY;

ssl/s3_msg.c:63:1: Parameter `s->session_ctx->sessions->num_items`
        61.   }
        62.   
        63. > int ssl3_send_alert(SSL *s, int level, int desc)
        64.   {
        65.       /* Map tls/ssl alert value to correct one */

ssl/s3_msg.c:77:9: Call
        75.       /* If a fatal one, remove from cache */
        76.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
        77.           SSL_CTX_remove_session(s->session_ctx, s->session);
                      ^
        78.   
        79.       s->s3->alert_dispatch = 1;

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

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

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

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

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

ssl/ssl_locl.h:688:1: Call
              686.   } CLIENTHELLO_MSG;
              687.   
              688. > DEFINE_LHASH_OF(SSL_SESSION);
              689.   /* Needed in ssl_cert.c */
              690.   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 `SSL_accept` 
                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 test_record_plain_overflow(int idx)\n{\n    SSL_CTX *cctx = NULL, *sctx = NULL;\n    SSL *clientssl = NULL, *serverssl = NULL;\n    int testresult = 0;\n    size_t len = 0;\n    size_t written;\n    int overf_expected;\n    unsigned char buf;\n    BIO *serverbio;\n    int recversion;\n#ifdef OPENSSL_NO_TLS1_2\n    if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_OK\n            || idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK)\n        return 1;\n#endif\n#ifdef OPENSSL_NO_TLS1_3\n    if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_OK\n            || idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK)\n        return 1;\n#endif\n    ERR_clear_error();\n    if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,\n                             &cctx, cert, privkey)) {\n        printf("Unable to create SSL_CTX pair\\n");\n        goto end;\n    }\n    if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_OK\n            || idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK) {\n        len = SSL3_RT_MAX_ENCRYPTED_LENGTH - SSL3_RT_MAX_COMPRESSED_OVERHEAD;\n        SSL_CTX_set_max_proto_version(sctx, TLS1_2_VERSION);\n    } else if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_OK\n               || idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK) {\n        len = SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH;\n    }\n    if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {\n        printf("Unable to create SSL objects\\n");\n        goto end;\n    }\n    serverbio = SSL_get_rbio(serverssl);\n    if (idx == TEST_PLAINTEXT_OVERFLOW_OK\n            || idx == TEST_PLAINTEXT_OVERFLOW_NOT_OK) {\n        len = SSL3_RT_MAX_PLAIN_LENGTH;\n        if (idx == TEST_PLAINTEXT_OVERFLOW_NOT_OK)\n            len++;\n        if (!write_record(serverbio, len, SSL3_RT_HANDSHAKE, TLS1_VERSION)) {\n            printf("Unable to write plaintext record\\n");\n            goto end;\n        }\n        if (SSL_accept(serverssl) > 0) {\n            printf("Unexpected success reading plaintext record\\n");\n            goto end;\n        }\n        overf_expected = (idx == TEST_PLAINTEXT_OVERFLOW_OK) ? 0 : 1;\n        if (fail_due_to_record_overflow(0) != overf_expected) {\n            printf("Unexpected error value received\\n");\n            goto end;\n        }\n        goto success;\n    }\n    if (!create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)) {\n        printf("Unable to create SSL connection\\n");\n        goto end;\n    }\n    if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_2_NOT_OK\n            || idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK) {\n        overf_expected = 1;\n        len++;\n    } else {\n        overf_expected = 0;\n    }\n    if (idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_OK\n            || idx == TEST_ENCRYPTED_OVERFLOW_TLS1_3_NOT_OK)\n        recversion = TLS1_VERSION;\n    else\n        recversion = TLS1_2_VERSION;\n    if (!write_record(serverbio, len, SSL3_RT_APPLICATION_DATA, recversion)) {\n        printf("Unable to write encryprted record\\n");\n        goto end;\n    }\n    if (SSL_read_ex(serverssl, &buf, sizeof(buf), &written)) {\n        printf("Unexpected success reading encrypted record\\n");\n        goto end;\n    }\n    if (fail_due_to_record_overflow(1) != overf_expected) {\n        printf("Unexpected error value received\\n");\n        goto end;\n    }\n success:\n    testresult = 1;\n end:\n    if(!testresult)\n        ERR_print_errors_fp(stdout);\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, *clientssl;\n    BIO *s_to_c_bio = NULL, *c_to_s_bio = NULL;\n    if (*sssl == NULL)\n        serverssl = SSL_new(serverctx);\n    else\n        serverssl = *sssl;\n    if (*cssl == NULL)\n        clientssl = SSL_new(clientctx);\n    else\n        clientssl = *cssl;\n    if (serverssl == NULL || clientssl == NULL) {\n        printf("Failed to create SSL object\\n");\n        goto error;\n    }\n    if (SSL_is_dtls(clientssl)) {\n        s_to_c_bio = BIO_new(bio_s_mempacket_test());\n        c_to_s_bio = BIO_new(bio_s_mempacket_test());\n    } else {\n        s_to_c_bio = BIO_new(BIO_s_mem());\n        c_to_s_bio = BIO_new(BIO_s_mem());\n    }\n    if (s_to_c_bio == NULL || c_to_s_bio == NULL) {\n        printf("Failed to create mem BIOs\\n");\n        goto error;\n    }\n    if (s_to_c_fbio != NULL)\n        s_to_c_bio = BIO_push(s_to_c_fbio, s_to_c_bio);\n    if (c_to_s_fbio != NULL)\n        c_to_s_bio = BIO_push(c_to_s_fbio, c_to_s_bio);\n    if (s_to_c_bio == NULL || c_to_s_bio == NULL) {\n        printf("Failed to create chained BIOs\\n");\n        goto error;\n    }\n    BIO_set_mem_eof_return(s_to_c_bio, -1);\n    BIO_set_mem_eof_return(c_to_s_bio, -1);\n    BIO_up_ref(s_to_c_bio);\n    BIO_up_ref(c_to_s_bio);\n    SSL_set_bio(serverssl, c_to_s_bio, s_to_c_bio);\n    SSL_set_bio(clientssl, s_to_c_bio, c_to_s_bio);\n    s_to_c_bio = c_to_s_bio = NULL;\n    s_to_c_fbio = c_to_s_fbio = NULL;\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->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 SSL_accept(SSL *s)\n{\n    if (s->handshake_func == NULL) {\n        SSL_set_accept_state(s);\n    }\n    return SSL_do_handshake(s);\n}', 'int SSL_do_handshake(SSL *s)\n{\n    int ret = 1;\n    if (s->handshake_func == NULL) {\n        SSLerr(SSL_F_SSL_DO_HANDSHAKE, SSL_R_CONNECTION_TYPE_NOT_SET);\n        return -1;\n    }\n    if (s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY) {\n        int edfin;\n        edfin = ssl_write_early_finish(s);\n        if (edfin <= 0)\n            return edfin;\n    }\n    ossl_statem_check_finish_init(s, -1);\n    s->method->ssl_renegotiate_check(s, 0);\n    if (SSL_in_init(s) || SSL_in_before(s)) {\n        if ((s->mode & SSL_MODE_ASYNC) && ASYNC_get_current_job() == NULL) {\n            struct ssl_async_args args;\n            args.s = s;\n            ret = ssl_start_async_job(s, &args, ssl_do_handshake_intern);\n        } else {\n            ret = s->handshake_func(s);\n        }\n    }\n    return ret;\n}', 'static int ssl_write_early_finish(SSL *s)\n{\n    int ret;\n    if (s->early_data_state != SSL_EARLY_DATA_WRITE_RETRY) {\n        SSLerr(SSL_F_SSL_WRITE_EARLY_FINISH, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    s->early_data_state = SSL_EARLY_DATA_WRITING;\n    ret = ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_END_OF_EARLY_DATA);\n    if (ret <= 0) {\n        s->early_data_state = SSL_EARLY_DATA_WRITE_RETRY;\n        return 0;\n    }\n    s->early_data_state = SSL_EARLY_DATA_FINISHED_WRITING;\n    EVP_CIPHER_CTX_free(s->enc_write_ctx);\n    s->enc_write_ctx = NULL;\n    ossl_statem_set_in_init(s, 1);\n    return 1;\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\n    if (SSL_TREAT_AS_TLS13(s))\n        desc = tls13_alert_code(desc);\n    else\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->session_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_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}']