ssl/ssl_sess.c:596: error: INTEGER_OVERFLOW_L2
  ([0, 1+max(0, `s->session_ctx->sessions->num_items`)] - 1):unsigned64 by call to `SSL_CTX_remove_session`.
Showing all 11 steps of the trace


ssl/ssl_sess.c:461:1: Parameter `s->session_ctx->sessions->num_items`
459.    *     if the server should issue a new session ticket (to 0 otherwise).
460.    */
461. > int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)
462.   {
463.       /* This is used only by servers. */

ssl/ssl_sess.c:596:13: Call
594.           if (try_session_cache) {
595.               /* session was from the cache, so remove it */
596.               SSL_CTX_remove_session(s->session_ctx, ret);
                   ^
597.           }
598.           goto err;

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

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

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

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

ssl/ssl_locl.h:660:1: Parameter `lh->num_items`
      658.   } CLIENTHELLO_MSG;
      659.   
      660. > DEFINE_LHASH_OF(SSL_SESSION);
      661.   /* Needed in ssl_cert.c */
      662.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:660:1: Call
      658.   } CLIENTHELLO_MSG;
      659.   
      660. > DEFINE_LHASH_OF(SSL_SESSION);
      661.   /* Needed in ssl_cert.c */
      662.   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, 1+max(0, s->session_ctx->sessions->num_items)] - 1):unsigned64 by call to `SSL_CTX_remove_session` 
        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);
}
['int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello, int *al)\n{\n    SSL_SESSION *ret = NULL;\n    int fatal = 0;\n    int try_session_cache = 0;\n    TICKET_RETURN r;\n    if (SSL_IS_TLS13(s)) {\n        if (!tls_parse_extension(s, TLSEXT_IDX_psk_kex_modes, EXT_CLIENT_HELLO,\n                                 hello->pre_proc_exts, NULL, 0, al)\n                || !tls_parse_extension(s, TLSEXT_IDX_psk, EXT_CLIENT_HELLO,\n                                        hello->pre_proc_exts, NULL, 0, al))\n            return -1;\n        ret = s->session;\n    } else {\n        r = tls_get_ticket_from_client(s, hello, &ret);\n        switch (r) {\n        case TICKET_FATAL_ERR_MALLOC:\n        case TICKET_FATAL_ERR_OTHER:\n            fatal = 1;\n            goto err;\n        case TICKET_NONE:\n        case TICKET_EMPTY:\n            try_session_cache = 1;\n            break;\n        case TICKET_NO_DECRYPT:\n        case TICKET_SUCCESS:\n        case TICKET_SUCCESS_RENEW:\n            break;\n        }\n    }\n    if (try_session_cache &&\n        ret == NULL &&\n        !(s->session_ctx->session_cache_mode &\n          SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) {\n        SSL_SESSION data;\n        data.ssl_version = s->version;\n        memset(data.session_id, 0, sizeof(data.session_id));\n        memcpy(data.session_id, hello->session_id, hello->session_id_len);\n        data.session_id_length = hello->session_id_len;\n        CRYPTO_THREAD_read_lock(s->session_ctx->lock);\n        ret = lh_SSL_SESSION_retrieve(s->session_ctx->sessions, &data);\n        if (ret != NULL) {\n            SSL_SESSION_up_ref(ret);\n        }\n        CRYPTO_THREAD_unlock(s->session_ctx->lock);\n        if (ret == NULL)\n            s->session_ctx->stats.sess_miss++;\n    }\n    if (try_session_cache &&\n        ret == NULL && s->session_ctx->get_session_cb != NULL) {\n        int copy = 1;\n        ret = s->session_ctx->get_session_cb(s, hello->session_id,\n                                             hello->session_id_len,\n                                             &copy);\n        if (ret != NULL) {\n            s->session_ctx->stats.sess_cb_hit++;\n            if (copy)\n                SSL_SESSION_up_ref(ret);\n            if (!\n                (s->session_ctx->session_cache_mode &\n                 SSL_SESS_CACHE_NO_INTERNAL_STORE)) {\n                if (SSL_CTX_add_session(s->session_ctx, ret))\n                    goto err;\n            }\n        }\n    }\n    if (ret == NULL)\n        goto err;\n    if (ret->ssl_version != s->version)\n        goto err;\n    if (ret->sid_ctx_length != s->sid_ctx_length\n        || memcmp(ret->sid_ctx, s->sid_ctx, ret->sid_ctx_length)) {\n        goto err;\n    }\n    if ((s->verify_mode & SSL_VERIFY_PEER) && s->sid_ctx_length == 0) {\n        SSLerr(SSL_F_SSL_GET_PREV_SESSION,\n               SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED);\n        fatal = 1;\n        goto err;\n    }\n    if (ret->timeout < (long)(time(NULL) - ret->time)) {\n        s->session_ctx->stats.sess_timeout++;\n        if (try_session_cache) {\n            SSL_CTX_remove_session(s->session_ctx, ret);\n        }\n        goto err;\n    }\n    if (ret->flags & SSL_SESS_FLAG_EXTMS) {\n        if (!(s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS)) {\n            SSLerr(SSL_F_SSL_GET_PREV_SESSION, SSL_R_INCONSISTENT_EXTMS);\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n            fatal = 1;\n            goto err;\n        }\n    } else if (s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) {\n        goto err;\n    }\n    if (!SSL_IS_TLS13(s)) {\n        SSL_SESSION_free(s->session);\n        s->session = ret;\n    }\n    s->session_ctx->stats.sess_hit++;\n    s->verify_result = s->session->verify_result;\n    return 1;\n err:\n    if (ret != NULL) {\n        SSL_SESSION_free(ret);\n        if (SSL_IS_TLS13(s))\n            s->session = NULL;\n        if (!try_session_cache) {\n            s->ext.ticket_expected = 1;\n        }\n    }\n    if (fatal) {\n        *al = SSL_AD_INTERNAL_ERROR;\n        return -1;\n    }\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}']