apps/s_time.c:619: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `SSL_free`.
Showing all 14 steps of the trace


apps/s_time.c:577:21: Call
575.   
576.       if (scon == NULL)
577.           serverCon = SSL_new(tm_ctx);
                           ^
578.       else {
579.           serverCon = scon;

ssl/ssl_lib.c:283:1: Parameter `ctx->sessions->num_nodes`
  281.   }
  282.   
  283. > SSL *SSL_new(SSL_CTX *ctx)
  284.   {
  285.       SSL *s;

apps/s_time.c:619:13: Call
617.               ERR_print_errors(bio_err);
618.           if (scon == NULL)
619.               SSL_free(serverCon);
                   ^
620.           return NULL;
621.       }

ssl/ssl_lib.c:541:1: Parameter `s->initial_ctx->sessions->num_nodes`
  539.   }
  540.   
  541. > void SSL_free(SSL *s)
  542.   {
  543.       int i;

ssl/ssl_lib.c:606:9: Call
  604.           OPENSSL_free(s->tlsext_hostname);
  605.       if (s->initial_ctx)
  606.           SSL_CTX_free(s->initial_ctx);
                 ^
  607.   # ifndef OPENSSL_NO_EC
  608.       if (s->tlsext_ecpointformatlist)

ssl/ssl_lib.c:2081:1: Parameter `a->sessions->num_nodes`
    2079.   #endif
    2080.   
    2081. > void SSL_CTX_free(SSL_CTX *a)
    2082.   {
    2083.       int i;

ssl/ssl_lib.c:2114:9: Call
    2112.        */
    2113.       if (a->sessions != NULL)
    2114.           SSL_CTX_flush_sessions(a, 0);
                    ^
    2115.   
    2116.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);

ssl/ssl_sess.c:971:1: Parameter `s->sessions->num_nodes`
      969.   static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION, TIMEOUT_PARAM)
      970.   
      971. > void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
      972.   {
      973.       unsigned long i;

ssl/ssl_sess.c:984:5: Call
      982.       i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;
      983.       CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0;
      984.       lh_SSL_SESSION_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout),
                 ^
      985.                                TIMEOUT_PARAM, &tp);
      986.       CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i;

crypto/lhash/lhash.c:298:1: Parameter `lh->num_nodes`
        296.   }
        297.   
        298. > void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
        299.   {
        300.       doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);

crypto/lhash/lhash.c:300:5: Call
        298.   void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
        299.   {
        300.       doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
                   ^
        301.   }
        302.   

crypto/lhash/lhash.c:260:1: <LHS trace>
258.   }
259.   
260. > static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
261.                             LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
262.   {

crypto/lhash/lhash.c:260:1: Parameter `lh->num_nodes`
          258.   }
          259.   
          260. > static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
          261.                             LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
          262.   {

crypto/lhash/lhash.c:273:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `SSL_free` 
          271.        * memory leaks otherwise
          272.        */
          273.       for (i = lh->num_nodes - 1; i >= 0; i--) {
                          ^
          274.           a = lh->b[i];
          275.           while (a != NULL) {

static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
                          LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
{
    int i;
    LHASH_NODE *a, *n;
    if (lh == NULL)
        return;
    for (i = lh->num_nodes - 1; i >= 0; i--) {
        a = lh->b[i];
        while (a != NULL) {
            n = a->next;
            if (use_arg)
                func_arg(a->data, arg);
            else
                func(a->data);
            a = n;
        }
    }
}
['static SSL *doConnection(SSL *scon)\n{\n    BIO *conn;\n    SSL *serverCon;\n    int width, i;\n    fd_set readfds;\n    if ((conn = BIO_new(BIO_s_connect())) == NULL)\n        return (NULL);\n    BIO_set_conn_hostname(conn, host);\n    if (scon == NULL)\n        serverCon = SSL_new(tm_ctx);\n    else {\n        serverCon = scon;\n        SSL_set_connect_state(serverCon);\n    }\n    SSL_set_bio(serverCon, conn, conn);\n#if 0\n    if (scon != NULL)\n        SSL_set_session(serverCon, SSL_get_session(scon));\n#endif\n    for (;;) {\n        i = SSL_connect(serverCon);\n        if (BIO_sock_should_retry(i)) {\n            BIO_printf(bio_err, "DELAY\\n");\n            i = SSL_get_fd(serverCon);\n            width = i + 1;\n            FD_ZERO(&readfds);\n            openssl_fdset(i, &readfds);\n            select(width, (void *)&readfds, NULL, NULL, NULL);\n            continue;\n        }\n        break;\n    }\n    if (i <= 0) {\n        BIO_printf(bio_err, "ERROR\\n");\n        if (verify_error != X509_V_OK)\n            BIO_printf(bio_err, "verify error:%s\\n",\n                       X509_verify_cert_error_string(verify_error));\n        else\n            ERR_print_errors(bio_err);\n        if (scon == NULL)\n            SSL_free(serverCon);\n        return NULL;\n    }\n    return serverCon;\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 = (SSL *)OPENSSL_malloc(sizeof(SSL));\n    if (s == NULL)\n        goto err;\n    memset(s, 0, sizeof(SSL));\n#ifndef OPENSSL_NO_KRB5\n    s->kssl_ctx = kssl_ctx_new();\n#endif\n    s->options = ctx->options;\n    s->mode = ctx->mode;\n    s->max_cert_list = ctx->max_cert_list;\n    if (ctx->cert != NULL) {\n        s->cert = ssl_cert_dup(ctx->cert);\n        if (s->cert == NULL)\n            goto err;\n    } else\n        s->cert = NULL;\n    s->read_ahead = 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#if 0\n    s->verify_depth = ctx->verify_depth;\n#endif\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)\n        goto err;\n    X509_VERIFY_PARAM_inherit(s->param, ctx->param);\n#if 0\n    s->purpose = ctx->purpose;\n    s->trust = ctx->trust;\n#endif\n    s->quiet_shutdown = ctx->quiet_shutdown;\n    s->max_send_fragment = ctx->max_send_fragment;\n    CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);\n    s->ctx = ctx;\n#ifndef OPENSSL_NO_TLSEXT\n    s->tlsext_debug_cb = 0;\n    s->tlsext_debug_arg = NULL;\n    s->tlsext_ticket_expected = 0;\n    s->tlsext_status_type = -1;\n    s->tlsext_status_expected = 0;\n    s->tlsext_ocsp_ids = NULL;\n    s->tlsext_ocsp_exts = NULL;\n    s->tlsext_ocsp_resp = NULL;\n    s->tlsext_ocsp_resplen = -1;\n    CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);\n    s->initial_ctx = ctx;\n# ifndef OPENSSL_NO_EC\n    if (ctx->tlsext_ecpointformatlist) {\n        s->tlsext_ecpointformatlist =\n            BUF_memdup(ctx->tlsext_ecpointformatlist,\n                       ctx->tlsext_ecpointformatlist_length);\n        if (!s->tlsext_ecpointformatlist)\n            goto err;\n        s->tlsext_ecpointformatlist_length =\n            ctx->tlsext_ecpointformatlist_length;\n    }\n    if (ctx->tlsext_ellipticcurvelist) {\n        s->tlsext_ellipticcurvelist =\n            BUF_memdup(ctx->tlsext_ellipticcurvelist,\n                       ctx->tlsext_ellipticcurvelist_length);\n        if (!s->tlsext_ellipticcurvelist)\n            goto err;\n        s->tlsext_ellipticcurvelist_length =\n            ctx->tlsext_ellipticcurvelist_length;\n    }\n# endif\n# ifndef OPENSSL_NO_NEXTPROTONEG\n    s->next_proto_negotiated = NULL;\n# endif\n    if (s->ctx->alpn_client_proto_list) {\n        s->alpn_client_proto_list =\n            OPENSSL_malloc(s->ctx->alpn_client_proto_list_len);\n        if (s->alpn_client_proto_list == NULL)\n            goto err;\n        memcpy(s->alpn_client_proto_list, s->ctx->alpn_client_proto_list,\n               s->ctx->alpn_client_proto_list_len);\n        s->alpn_client_proto_list_len = s->ctx->alpn_client_proto_list_len;\n    }\n#endif\n    s->verify_result = X509_V_OK;\n    s->method = ctx->method;\n    if (!s->method->ssl_new(s))\n        goto err;\n    s->references = 1;\n    s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;\n    SSL_clear(s);\n    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\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    return (s);\n err:\n    if (s != NULL)\n        SSL_free(s);\n    SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n    return (NULL);\n}', 'void SSL_free(SSL *s)\n{\n    int i;\n    if (s == NULL)\n        return;\n    i = CRYPTO_add(&s->references, -1, CRYPTO_LOCK_SSL);\n#ifdef REF_PRINT\n    REF_PRINT("SSL", s);\n#endif\n    if (i > 0)\n        return;\n#ifdef REF_CHECK\n    if (i < 0) {\n        fprintf(stderr, "SSL_free, bad reference count\\n");\n        abort();\n    }\n#endif\n    if (s->param)\n        X509_VERIFY_PARAM_free(s->param);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n    if (s->bbio != NULL) {\n        if (s->bbio == s->wbio) {\n            s->wbio = BIO_pop(s->wbio);\n        }\n        BIO_free(s->bbio);\n        s->bbio = NULL;\n    }\n    if (s->rbio != NULL)\n        BIO_free_all(s->rbio);\n    if ((s->wbio != NULL) && (s->wbio != s->rbio))\n        BIO_free_all(s->wbio);\n    if (s->init_buf != NULL)\n        BUF_MEM_free(s->init_buf);\n    if (s->cipher_list != NULL)\n        sk_SSL_CIPHER_free(s->cipher_list);\n    if (s->cipher_list_by_id != NULL)\n        sk_SSL_CIPHER_free(s->cipher_list_by_id);\n    if (s->session != NULL) {\n        ssl_clear_bad_session(s);\n        SSL_SESSION_free(s->session);\n    }\n    ssl_clear_cipher_ctx(s);\n    ssl_clear_hash_ctx(&s->read_hash);\n    ssl_clear_hash_ctx(&s->write_hash);\n    if (s->cert != NULL)\n        ssl_cert_free(s->cert);\n#ifndef OPENSSL_NO_TLSEXT\n    if (s->tlsext_hostname)\n        OPENSSL_free(s->tlsext_hostname);\n    if (s->initial_ctx)\n        SSL_CTX_free(s->initial_ctx);\n# ifndef OPENSSL_NO_EC\n    if (s->tlsext_ecpointformatlist)\n        OPENSSL_free(s->tlsext_ecpointformatlist);\n    if (s->tlsext_ellipticcurvelist)\n        OPENSSL_free(s->tlsext_ellipticcurvelist);\n# endif\n    if (s->tlsext_opaque_prf_input)\n        OPENSSL_free(s->tlsext_opaque_prf_input);\n    if (s->tlsext_ocsp_exts)\n        sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free);\n    if (s->tlsext_ocsp_ids)\n        sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free);\n    if (s->tlsext_ocsp_resp)\n        OPENSSL_free(s->tlsext_ocsp_resp);\n    if (s->alpn_client_proto_list)\n        OPENSSL_free(s->alpn_client_proto_list);\n#endif\n    if (s->client_CA != NULL)\n        sk_X509_NAME_pop_free(s->client_CA, X509_NAME_free);\n    if (s->method != NULL)\n        s->method->ssl_free(s);\n    if (s->ctx)\n        SSL_CTX_free(s->ctx);\n#ifndef OPENSSL_NO_KRB5\n    if (s->kssl_ctx != NULL)\n        kssl_ctx_free(s->kssl_ctx);\n#endif\n#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)\n    if (s->next_proto_negotiated)\n        OPENSSL_free(s->next_proto_negotiated);\n#endif\n#ifndef OPENSSL_NO_SRTP\n    if (s->srtp_profiles)\n        sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles);\n#endif\n    OPENSSL_free(s);\n}', 'void SSL_CTX_free(SSL_CTX *a)\n{\n    int i;\n    if (a == NULL)\n        return;\n    i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_SSL_CTX);\n#ifdef REF_PRINT\n    REF_PRINT("SSL_CTX", a);\n#endif\n    if (i > 0)\n        return;\n#ifdef REF_CHECK\n    if (i < 0) {\n        fprintf(stderr, "SSL_CTX_free, bad reference count\\n");\n        abort();\n    }\n#endif\n    if (a->param)\n        X509_VERIFY_PARAM_free(a->param);\n    if (a->sessions != NULL)\n        SSL_CTX_flush_sessions(a, 0);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);\n    if (a->sessions != NULL)\n        lh_SSL_SESSION_free(a->sessions);\n    if (a->cert_store != NULL)\n        X509_STORE_free(a->cert_store);\n    if (a->cipher_list != NULL)\n        sk_SSL_CIPHER_free(a->cipher_list);\n    if (a->cipher_list_by_id != NULL)\n        sk_SSL_CIPHER_free(a->cipher_list_by_id);\n    if (a->cert != NULL)\n        ssl_cert_free(a->cert);\n    if (a->client_CA != NULL)\n        sk_X509_NAME_pop_free(a->client_CA, X509_NAME_free);\n    if (a->extra_certs != NULL)\n        sk_X509_pop_free(a->extra_certs, X509_free);\n#if 0\n    if (a->comp_methods != NULL)\n        sk_SSL_COMP_pop_free(a->comp_methods, SSL_COMP_free);\n#else\n    a->comp_methods = NULL;\n#endif\n#ifndef OPENSSL_NO_SRTP\n    if (a->srtp_profiles)\n        sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles);\n#endif\n#ifndef OPENSSL_NO_PSK\n    if (a->psk_identity_hint)\n        OPENSSL_free(a->psk_identity_hint);\n#endif\n#ifndef OPENSSL_NO_SRP\n    SSL_CTX_SRP_CTX_free(a);\n#endif\n#ifndef OPENSSL_NO_ENGINE\n    if (a->client_cert_engine)\n        ENGINE_finish(a->client_cert_engine);\n#endif\n#ifndef OPENSSL_NO_BUF_FREELISTS\n    if (a->wbuf_freelist)\n        ssl_buf_freelist_free(a->wbuf_freelist);\n    if (a->rbuf_freelist)\n        ssl_buf_freelist_free(a->rbuf_freelist);\n#endif\n#ifndef OPENSSL_NO_TLSEXT\n# ifndef OPENSSL_NO_EC\n    if (a->tlsext_ecpointformatlist)\n        OPENSSL_free(a->tlsext_ecpointformatlist);\n    if (a->tlsext_ellipticcurvelist)\n        OPENSSL_free(a->tlsext_ellipticcurvelist);\n# endif\n    if (a->alpn_client_proto_list != NULL)\n        OPENSSL_free(a->alpn_client_proto_list);\n#endif\n    OPENSSL_free(a);\n}', 'void SSL_CTX_flush_sessions(SSL_CTX *s, long t)\n{\n    unsigned long i;\n    TIMEOUT_PARAM tp;\n    tp.ctx = s;\n    tp.cache = s->sessions;\n    if (tp.cache == NULL)\n        return;\n    tp.time = t;\n    CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);\n    i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;\n    CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0;\n    lh_SSL_SESSION_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout),\n                             TIMEOUT_PARAM, &tp);\n    CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i;\n    CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);\n}', 'void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)\n{\n    doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);\n}', 'static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,\n                          LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)\n{\n    int i;\n    LHASH_NODE *a, *n;\n    if (lh == NULL)\n        return;\n    for (i = lh->num_nodes - 1; i >= 0; i--) {\n        a = lh->b[i];\n        while (a != NULL) {\n            n = a->next;\n            if (use_arg)\n                func_arg(a->data, arg);\n            else\n                func(a->data);\n            a = n;\n        }\n    }\n}']