ssl/ssl_sess.c:608: 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:467:1: Parameter `s->session_ctx->sessions->num_items`
465.    *     if the server should issue a new session ticket (to 0 otherwise).
466.    */
467. > int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello)
468.   {
469.       /* This is used only by servers. */

ssl/ssl_sess.c:608:13: Call
606.           if (try_session_cache) {
607.               /* session was from the cache, so remove it */
608.               SSL_CTX_remove_session(s->session_ctx, ret);
                   ^
609.           }
610.           goto err;

ssl/ssl_sess.c:737:1: Parameter `ctx->sessions->num_items`
  735.   }
  736.   
  737. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
  738.   {
  739.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:739:12: Call
  737.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
  738.   {
  739.       return remove_session_lock(ctx, c, 1);
                    ^
  740.   }
  741.   

ssl/ssl_sess.c:742:1: Parameter `ctx->sessions->num_items`
    740.   }
    741.   
    742. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
    743.   {
    744.       SSL_SESSION *r;

ssl/ssl_sess.c:752:17: Call
    750.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
    751.               ret = 1;
    752.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                           ^
    753.               SSL_SESSION_list_remove(ctx, c);
    754.           }

ssl/ssl_locl.h:713:1: Parameter `lh->num_items`
      711.   } TLSEXT_INDEX;
      712.   
      713. > DEFINE_LHASH_OF(SSL_SESSION);
      714.   /* Needed in ssl_cert.c */
      715.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:713:1: Call
      711.   } TLSEXT_INDEX;
      712.   
      713. > DEFINE_LHASH_OF(SSL_SESSION);
      714.   /* Needed in ssl_cert.c */
      715.   DEFINE_LHASH_OF(X509_NAME);

crypto/lhash/lhash.c:119:1: <LHS trace>
117.   }
118.   
119. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
120.   {
121.       unsigned long hash;

crypto/lhash/lhash.c:119:1: Parameter `lh->num_items`
        117.   }
        118.   
        119. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
        120.   {
        121.       unsigned long hash;

crypto/lhash/lhash.c:139:5: Binary operation: ([0, 1+max(0, s->session_ctx->sessions->num_items)] - 1):unsigned64 by call to `SSL_CTX_remove_session` 
        137.       }
        138.   
        139.       lh->num_items--;
                   ^
        140.       if ((lh->num_nodes > MIN_NODES) &&
        141.           (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)\n{\n    SSL_SESSION *ret = NULL;\n    int fatal = 0, discard;\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,\n                                 SSL_EXT_CLIENT_HELLO, hello->pre_proc_exts,\n                                 NULL, 0)\n                || !tls_parse_extension(s, TLSEXT_IDX_psk, SSL_EXT_CLIENT_HELLO,\n                                        hello->pre_proc_exts, NULL, 0))\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            SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_PREV_SESSION,\n                     ERR_R_INTERNAL_ERROR);\n            goto err;\n        case TICKET_NONE:\n        case TICKET_EMPTY:\n            if (hello->session_id_len > 0)\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        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            CRYPTO_atomic_add(&s->session_ctx->stats.sess_miss, 1, &discard,\n                              s->session_ctx->lock);\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            CRYPTO_atomic_add(&s->session_ctx->stats.sess_cb_hit, 1, &discard,\n                              s->session_ctx->lock);\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                SSL_CTX_add_session(s->session_ctx, ret);\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        SSLfatal(s, SSL_AD_INTERNAL_ERROR, 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        CRYPTO_atomic_add(&s->session_ctx->stats.sess_timeout, 1, &discard,\n                          s->session_ctx->lock);\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            SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SSL_GET_PREV_SESSION,\n                     SSL_R_INCONSISTENT_EXTMS);\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    CRYPTO_atomic_add(&s->session_ctx->stats.sess_hit, 1, &discard,\n                      s->session_ctx->lock);\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        return -1;\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}']