ssl/statem/statem_clnt.c:2325: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `s->session_ctx->sessions->num_items`)] - 1):unsigned64 by call to `ssl3_send_alert`.
Showing all 13 steps of the trace


ssl/statem/statem_clnt.c:2151:1: Parameter `s->session_ctx->sessions->num_items`
2149.   }
2150.   
2151. > MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt)
2152.   {
2153.       int al = -1;

ssl/statem/statem_clnt.c:2325:9: Call
2323.    err:
2324.       if (al != -1)
2325.           ssl3_send_alert(s, SSL3_AL_FATAL, al);
                ^
2326.       ossl_statem_set_error(s);
2327.       EVP_MD_CTX_free(md_ctx);

ssl/s3_msg.c:63:1: Parameter `s->session_ctx->sessions->num_items`
  61.   }
  62.   
  63. > int ssl3_send_alert(SSL *s, int level, int desc)
  64.   {
  65.       /* Map tls/ssl alert value to correct one */

ssl/s3_msg.c:77:9: Call
  75.       /* If a fatal one, remove from cache */
  76.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
  77.           SSL_CTX_remove_session(s->session_ctx, s->session);
                ^
  78.   
  79.       s->s3->alert_dispatch = 1;

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:721:1: Parameter `lh->num_items`
        719.   } TLSEXT_INDEX;
        720.   
        721. > DEFINE_LHASH_OF(SSL_SESSION);
        722.   /* Needed in ssl_cert.c */
        723.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:721:1: Call
        719.   } TLSEXT_INDEX;
        720.   
        721. > DEFINE_LHASH_OF(SSL_SESSION);
        722.   /* Needed in ssl_cert.c */
        723.   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, max(0, s->session_ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_send_alert` 
          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);
}
['MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt)\n{\n    int al = -1;\n    long alg_k;\n    EVP_PKEY *pkey = NULL;\n    EVP_MD_CTX *md_ctx = NULL;\n    EVP_PKEY_CTX *pctx = NULL;\n    PACKET save_param_start, signature;\n    alg_k = s->s3->tmp.new_cipher->algorithm_mkey;\n    save_param_start = *pkt;\n#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)\n    EVP_PKEY_free(s->s3->peer_tmp);\n    s->s3->peer_tmp = NULL;\n#endif\n    if (alg_k & SSL_PSK) {\n        if (!tls_process_ske_psk_preamble(s, pkt, &al))\n            goto err;\n    }\n    if (alg_k & (SSL_kPSK | SSL_kRSAPSK)) {\n    } else if (alg_k & SSL_kSRP) {\n        if (!tls_process_ske_srp(s, pkt, &pkey, &al))\n            goto err;\n    } else if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) {\n        if (!tls_process_ske_dhe(s, pkt, &pkey, &al))\n            goto err;\n    } else if (alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) {\n        if (!tls_process_ske_ecdhe(s, pkt, &pkey, &al))\n            goto err;\n    } else if (alg_k) {\n        al = SSL_AD_UNEXPECTED_MESSAGE;\n        SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE);\n        goto err;\n    }\n    if (pkey != NULL) {\n        PACKET params;\n        int maxsig;\n        const EVP_MD *md = NULL;\n        if (!PACKET_get_sub_packet(&save_param_start, &params,\n                                   PACKET_remaining(&save_param_start) -\n                                   PACKET_remaining(pkt))) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        if (SSL_USE_SIGALGS(s)) {\n            unsigned int sigalg;\n            int rv;\n            if (!PACKET_get_net_2(pkt, &sigalg)) {\n                al = SSL_AD_DECODE_ERROR;\n                SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n                goto err;\n            }\n            rv = tls12_check_peer_sigalg(s, sigalg, pkey);\n            if (rv == -1) {\n                al = SSL_AD_INTERNAL_ERROR;\n                goto err;\n            } else if (rv == 0) {\n                al = SSL_AD_DECODE_ERROR;\n                goto err;\n            }\n#ifdef SSL_DEBUG\n            fprintf(stderr, "USING TLSv1.2 HASH %s\\n", EVP_MD_name(md));\n#endif\n        } else if (!tls1_set_peer_legacy_sigalg(s, pkey)) {\n            al = SSL_AD_INTERNAL_ERROR;\n            goto err;\n        }\n        md = ssl_md(s->s3->tmp.peer_sigalg->hash_idx);\n        if (!PACKET_get_length_prefixed_2(pkt, &signature)\n            || PACKET_remaining(pkt) != 0) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH);\n            goto err;\n        }\n        maxsig = EVP_PKEY_size(pkey);\n        if (maxsig < 0) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        if (PACKET_remaining(&signature) > (size_t)maxsig) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE,\n                   SSL_R_WRONG_SIGNATURE_LENGTH);\n            goto err;\n        }\n        md_ctx = EVP_MD_CTX_new();\n        if (md_ctx == NULL) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        if (EVP_DigestVerifyInit(md_ctx, &pctx, md, NULL, pkey) <= 0) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_EVP_LIB);\n            goto err;\n        }\n        if (SSL_USE_PSS(s)) {\n            if (EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) <= 0\n                || EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx,\n                                                RSA_PSS_SALTLEN_DIGEST) <= 0) {\n                al = SSL_AD_INTERNAL_ERROR;\n                SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_EVP_LIB);\n                goto err;\n            }\n        }\n        if (EVP_DigestVerifyUpdate(md_ctx, &(s->s3->client_random[0]),\n                                   SSL3_RANDOM_SIZE) <= 0\n                || EVP_DigestVerifyUpdate(md_ctx, &(s->s3->server_random[0]),\n                                          SSL3_RANDOM_SIZE) <= 0\n                || EVP_DigestVerifyUpdate(md_ctx, PACKET_data(&params),\n                                          PACKET_remaining(&params)) <= 0) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_EVP_LIB);\n            goto err;\n        }\n        if (EVP_DigestVerifyFinal(md_ctx, PACKET_data(&signature),\n                                  PACKET_remaining(&signature)) <= 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE);\n            goto err;\n        }\n        EVP_MD_CTX_free(md_ctx);\n        md_ctx = NULL;\n    } else {\n        if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))\n            && !(alg_k & SSL_PSK)) {\n            if (ssl3_check_cert_and_algorithm(s)) {\n                al = SSL_AD_INTERNAL_ERROR;\n                SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            } else {\n                al = SSL_AD_DECODE_ERROR;\n            }\n            goto err;\n        }\n        if (PACKET_remaining(pkt) != 0) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_EXTRA_DATA_IN_MESSAGE);\n            goto err;\n        }\n    }\n    return MSG_PROCESS_CONTINUE_READING;\n err:\n    if (al != -1)\n        ssl3_send_alert(s, SSL3_AL_FATAL, al);\n    ossl_statem_set_error(s);\n    EVP_MD_CTX_free(md_ctx);\n    return MSG_PROCESS_ERROR;\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\n    if (SSL_TREAT_AS_TLS13(s))\n        desc = tls13_alert_code(desc);\n    else\n        desc = s->method->ssl3_enc->alert_value(desc);\n    if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)\n        desc = SSL_AD_HANDSHAKE_FAILURE;\n    if (desc < 0)\n        return -1;\n    if ((level == SSL3_AL_FATAL) && (s->session != NULL))\n        SSL_CTX_remove_session(s->session_ctx, s->session);\n    s->s3->alert_dispatch = 1;\n    s->s3->send_alert[0] = level;\n    s->s3->send_alert[1] = desc;\n    if (!RECORD_LAYER_write_pending(&s->rlayer)) {\n        return s->method->ssl_dispatch_alert(s);\n    }\n    return -1;\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}']