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


test/sslapitest.c:629:10: Call
627.       }
628.   
629.       if (!create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)) {
                ^
630.           printf("Unable to create SSL connection\n");
631.           goto end;

test/ssltestlib.c:654:20: Call
  652.           err = SSL_ERROR_WANT_WRITE;
  653.           while (!clienterr && retc <= 0 && err == SSL_ERROR_WANT_WRITE) {
  654.               retc = SSL_connect(clientssl);
                            ^
  655.               if (retc <= 0)
  656.                   err = SSL_get_error(clientssl, retc);

ssl/ssl_lib.c:1469:1: Parameter `s->session_ctx->sessions->num_items`
    1467.   }
    1468.   
    1469. > int SSL_connect(SSL *s)
    1470.   {
    1471.       if (s->handshake_func == NULL) {

ssl/ssl_lib.c:1476:12: Call
    1474.       }
    1475.   
    1476.       return SSL_do_handshake(s);
                       ^
    1477.   }
    1478.   

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

test/ssltestlib.c:654:20: Call
  652.           err = SSL_ERROR_WANT_WRITE;
  653.           while (!clienterr && retc <= 0 && err == SSL_ERROR_WANT_WRITE) {
  654.               retc = SSL_connect(clientssl);
                            ^
  655.               if (retc <= 0)
  656.                   err = SSL_get_error(clientssl, retc);

ssl/ssl_lib.c:1469:1: Parameter `s->session_ctx->sessions->num_items`
    1467.   }
    1468.   
    1469. > int SSL_connect(SSL *s)
    1470.   {
    1471.       if (s->handshake_func == NULL) {

ssl/ssl_lib.c:1476:12: Call
    1474.       }
    1475.   
    1476.       return SSL_do_handshake(s);
                       ^
    1477.   }
    1478.   

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

test/sslapitest.c:638:10: Call
636.        * doesn't leak (when using enable-crypto-mdebug).
637.        */
638.       if (!SSL_clear(serverssl)) {
                ^
639.           printf("Unexpected failure from SSL_clear()\n");
640.           goto end;

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

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

ssl/ssl_sess.c:1036:1: Parameter `s->session_ctx->sessions->num_items`
    1034.   }
    1035.   
    1036. > int ssl_clear_bad_session(SSL *s)
    1037.   {
    1038.       if ((s->session != NULL) &&

ssl/ssl_sess.c:1041:9: Call
    1039.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
    1040.           !(SSL_in_init(s) || SSL_in_before(s))) {
    1041.           SSL_CTX_remove_session(s->session_ctx, s->session);
                    ^
    1042.           return (1);
    1043.       } else

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_clear` 
            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 execute_test_large_message(const SSL_METHOD *smeth,\n                                      const SSL_METHOD *cmeth, int read_ahead)\n{\n    SSL_CTX *cctx = NULL, *sctx = NULL;\n    SSL *clientssl = NULL, *serverssl = NULL;\n    int testresult = 0;\n    int i;\n    BIO *certbio = BIO_new_file(cert, "r");\n    X509 *chaincert = NULL;\n    int certlen;\n    if (certbio == NULL) {\n        printf("Can\'t load the certficate file\\n");\n        goto end;\n    }\n    chaincert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);\n    BIO_free(certbio);\n    certbio = NULL;\n    if (chaincert == NULL) {\n        printf("Unable to load certificate for chain\\n");\n        goto end;\n    }\n    if (!create_ssl_ctx_pair(smeth, cmeth, &sctx,\n                             &cctx, cert, privkey)) {\n        printf("Unable to create SSL_CTX pair\\n");\n        goto end;\n    }\n    if(read_ahead) {\n        SSL_CTX_set_read_ahead(cctx, 1);\n    }\n    certlen = i2d_X509(chaincert, NULL);\n    OPENSSL_assert((certlen * NUM_EXTRA_CERTS)\n                   > ((SSL3_RT_MAX_PLAIN_LENGTH * 4) / 3));\n    for (i = 0; i < NUM_EXTRA_CERTS; i++) {\n        if (!X509_up_ref(chaincert)) {\n            printf("Unable to up ref cert\\n");\n            goto end;\n        }\n        if (!SSL_CTX_add_extra_chain_cert(sctx, chaincert)) {\n            printf("Unable to add extra chain cert %d\\n", i);\n            X509_free(chaincert);\n            goto end;\n        }\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    if (!create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)) {\n        printf("Unable to create SSL connection\\n");\n        goto end;\n    }\n    if (!SSL_clear(serverssl)) {\n        printf("Unexpected failure from SSL_clear()\\n");\n        goto end;\n    }\n    testresult = 1;\n end:\n    X509_free(chaincert);\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_connection(SSL *serverssl, SSL *clientssl, int want)\n{\n    int retc = -1, rets = -1, err, abortctr = 0;\n    int clienterr = 0, servererr = 0;\n    unsigned char buf;\n    size_t readbytes;\n    do {\n        err = SSL_ERROR_WANT_WRITE;\n        while (!clienterr && retc <= 0 && err == SSL_ERROR_WANT_WRITE) {\n            retc = SSL_connect(clientssl);\n            if (retc <= 0)\n                err = SSL_get_error(clientssl, retc);\n        }\n        if (!clienterr && retc <= 0 && err != SSL_ERROR_WANT_READ) {\n            printf("SSL_connect() failed %d, %d\\n", retc, err);\n            clienterr = 1;\n        }\n        if (want != SSL_ERROR_NONE && err == want)\n            return 0;\n        err = SSL_ERROR_WANT_WRITE;\n        while (!servererr && rets <= 0 && err == SSL_ERROR_WANT_WRITE) {\n            rets = SSL_accept(serverssl);\n            if (rets <= 0)\n                err = SSL_get_error(serverssl, rets);\n        }\n        if (!servererr && rets <= 0 && err != SSL_ERROR_WANT_READ) {\n            printf("SSL_accept() failed %d, %d\\n", rets, err);\n            servererr = 1;\n        }\n        if (want != SSL_ERROR_NONE && err == want)\n            return 0;\n        if (clienterr && servererr)\n            return 0;\n        if (++abortctr == MAXLOOPS) {\n            printf("No progress made\\n");\n            return 0;\n        }\n    } while (retc <=0 || rets <= 0);\n    if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) {\n        if (readbytes != 0) {\n            printf("Unexpected success reading data %"OSSLzu"\\n", readbytes);\n            return 0;\n        }\n    } else if (SSL_get_error(clientssl, 0) != SSL_ERROR_WANT_READ) {\n        printf("SSL_read_ex() failed\\n");\n        return 0;\n    }\n    return 1;\n}', 'int SSL_connect(SSL *s)\n{\n    if (s->handshake_func == NULL) {\n        SSL_set_connect_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}', '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}']