ssl/ssl_lib.c:394: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `ctx->sessions->num_items`)] - 1):unsigned64 by call to `SSL_free`.
Showing all 13 steps of the trace


ssl/ssl_lib.c:265:1: Parameter `ctx->sessions->num_items`
263.   }
264.   
265. > SSL *SSL_new(SSL_CTX *ctx)
266.   {
267.       SSL *s;

ssl/ssl_lib.c:394:9: Call
392.    err:
393.       if (s != NULL)
394.           SSL_free(s);
               ^
395.       SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);
396.       return (NULL);

ssl/ssl_lib.c:513:1: Parameter `s->ctx->sessions->num_items`
  511.   }
  512.   
  513. > void SSL_free(SSL *s)
  514.   {
  515.       int i;

ssl/ssl_lib.c:562:9: Call
  560.       /* Make the next call work :-) */
  561.       if (s->session != NULL) {
  562.           ssl_clear_bad_session(s);
                 ^
  563.           SSL_SESSION_free(s->session);
  564.       }

ssl/ssl_sess.c:1010:1: Parameter `s->ctx->sessions->num_items`
    1008.   }
    1009.   
    1010. > int ssl_clear_bad_session(SSL *s)
    1011.   {
    1012.       if ((s->session != NULL) &&

ssl/ssl_sess.c:1015:9: Call
    1013.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
    1014.           !(SSL_in_init(s) || SSL_in_before(s))) {
    1015.           SSL_CTX_remove_session(s->ctx, s->session);
                    ^
    1016.           return (1);
    1017.       } else

ssl/ssl_sess.c:675:1: Parameter `ctx->sessions->num_items`
      673.   }
      674.   
      675. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      676.   {
      677.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:677:12: Call
      675.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      676.   {
      677.       return remove_session_lock(ctx, c, 1);
                        ^
      678.   }
      679.   

ssl/ssl_sess.c:680:1: Parameter `ctx->sessions->num_items`
        678.   }
        679.   
        680. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        681.   {
        682.       SSL_SESSION *r;

ssl/ssl_sess.c:690:17: Call
        688.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
        689.               ret = 1;
        690.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                               ^
        691.               SSL_SESSION_list_remove(ctx, c);
        692.           }

crypto/lhash/lhash.c:211:1: <LHS trace>
209.   }
210.   
211. > void *lh_delete(_LHASH *lh, const void *data)
212.   {
213.       unsigned long hash;

crypto/lhash/lhash.c:211:1: Parameter `lh->num_items`
          209.   }
          210.   
          211. > void *lh_delete(_LHASH *lh, const void *data)
          212.   {
          213.       unsigned long hash;

crypto/lhash/lhash.c:231:5: Binary operation: ([0, max(0, ctx->sessions->num_items)] - 1):unsigned64 by call to `SSL_free` 
          229.       }
          230.   
          231.       lh->num_items--;
                     ^
          232.       if ((lh->num_nodes > MIN_NODES) &&
          233.           (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))

void *lh_delete(_LHASH *lh, const void *data)
{
    unsigned long hash;
    LHASH_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);
}
['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    s->cert = ssl_cert_dup(ctx->cert);\n    if (s->cert == NULL)\n        goto err;\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    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    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    if(!SSL_clear(s))\n        goto err;\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_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}', '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->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_w_lock(CRYPTO_LOCK_SSL_CTX);\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        if (lck)\n            CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);\n        if (ret) {\n            r->not_resumable = 1;\n            if (ctx->remove_session_cb != NULL)\n                ctx->remove_session_cb(ctx, r);\n            SSL_SESSION_free(r);\n        }\n    } else\n        ret = 0;\n    return (ret);\n}', 'void *lh_delete(_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    LHASH_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}']