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


ssl/statem/statem_clnt.c:2310:1: Parameter `s->ctx->sessions->num_items`
2308.   }
2309.   
2310. > enum MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt)
2311.   {
2312.       if (PACKET_remaining(pkt) > 0) {

ssl/statem/statem_clnt.c:2335:10: Call
2333.        * the server
2334.        */
2335.       if (!ssl3_check_cert_and_algorithm(s)) {
                 ^
2336.           ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
2337.           ossl_statem_set_error(s);

ssl/statem/statem_clnt.c:3248:1: Parameter `s->ctx->sessions->num_items`
  3246.   #define has_bits(i,m)   (((i)&(m)) == (m))
  3247.   
  3248. > int ssl3_check_cert_and_algorithm(SSL *s)
  3249.   {
  3250.       int i, idx;

ssl/statem/statem_clnt.c:2336:9: Call
2334.        */
2335.       if (!ssl3_check_cert_and_algorithm(s)) {
2336.           ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
                ^
2337.           ossl_statem_set_error(s);
2338.           return MSG_PROCESS_ERROR;

ssl/s3_msg.c:166:1: Parameter `s->ctx->sessions->num_items`
  164.   }
  165.   
  166. > int ssl3_send_alert(SSL *s, int level, int desc)
  167.   {
  168.       /* Map tls/ssl alert value to correct one */

ssl/s3_msg.c:177:9: Call
  175.       /* If a fatal one, remove from cache */
  176.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
  177.           SSL_CTX_remove_session(s->ctx, s->session);
                 ^
  178.   
  179.       s->s3->alert_dispatch = 1;

ssl/ssl_sess.c:776:1: Parameter `ctx->sessions->num_items`
    774.   }
    775.   
    776. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    777.   {
    778.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:778:12: Call
    776.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    777.   {
    778.       return remove_session_lock(ctx, c, 1);
                      ^
    779.   }
    780.   

ssl/ssl_sess.c:781:1: Parameter `ctx->sessions->num_items`
      779.   }
      780.   
      781. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
      782.   {
      783.       SSL_SESSION *r;

ssl/ssl_sess.c:791:17: Call
      789.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
      790.               ret = 1;
      791.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                             ^
      792.               SSL_SESSION_list_remove(ctx, c);
      793.           }

crypto/lhash/lhash.c:189:1: <LHS trace>
187.   }
188.   
189. > void *lh_delete(_LHASH *lh, const void *data)
190.   {
191.       unsigned long hash;

crypto/lhash/lhash.c:189:1: Parameter `lh->num_items`
        187.   }
        188.   
        189. > void *lh_delete(_LHASH *lh, const void *data)
        190.   {
        191.       unsigned long hash;

crypto/lhash/lhash.c:209:5: Binary operation: ([0, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_send_alert` 
        207.       }
        208.   
        209.       lh->num_items--;
                   ^
        210.       if ((lh->num_nodes > MIN_NODES) &&
        211.           (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);
}
['enum MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt)\n{\n    if (PACKET_remaining(pkt) > 0) {\n        ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_DONE, SSL_R_LENGTH_MISMATCH);\n        ossl_statem_set_error(s);\n        return MSG_PROCESS_ERROR;\n    }\n#ifndef OPENSSL_NO_SRP\n    if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) {\n        if (SRP_Calc_A_param(s) <= 0) {\n            SSLerr(SSL_F_TLS_PROCESS_SERVER_DONE, SSL_R_SRP_A_CALC);\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n            ossl_statem_set_error(s);\n            return MSG_PROCESS_ERROR;\n        }\n    }\n#endif\n    if (!ssl3_check_cert_and_algorithm(s)) {\n        ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n        ossl_statem_set_error(s);\n        return MSG_PROCESS_ERROR;\n    }\n#ifndef OPENSSL_NO_SCTP\n    if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))\n            && s->renegotiate != 0)\n        return MSG_PROCESS_CONTINUE_PROCESSING;\n    else\n#endif\n        return MSG_PROCESS_FINISHED_READING;\n}', 'int ssl3_check_cert_and_algorithm(SSL *s)\n{\n    int i, idx;\n    long alg_k, alg_a;\n    EVP_PKEY *pkey = NULL;\n    int pkey_bits;\n#ifndef OPENSSL_NO_RSA\n    RSA *rsa;\n#endif\n#ifndef OPENSSL_NO_DH\n    DH *dh;\n#endif\n    int al = SSL_AD_HANDSHAKE_FAILURE;\n    alg_k = s->s3->tmp.new_cipher->algorithm_mkey;\n    alg_a = s->s3->tmp.new_cipher->algorithm_auth;\n    if ((alg_a & SSL_aNULL) || (alg_k & SSL_kPSK))\n        return (1);\n#ifndef OPENSSL_NO_RSA\n    rsa = s->s3->peer_rsa_tmp;\n#endif\n#ifndef OPENSSL_NO_DH\n    dh = s->s3->peer_dh_tmp;\n#endif\n    idx = s->session->peer_type;\n#ifndef OPENSSL_NO_EC\n    if (idx == SSL_PKEY_ECC) {\n        if (ssl_check_srvr_ecc_cert_and_alg(s->session->peer, s) == 0) {\n            SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_BAD_ECC_CERT);\n            goto f_err;\n        } else {\n            return 1;\n        }\n    } else if (alg_a & SSL_aECDSA) {\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n               SSL_R_MISSING_ECDSA_SIGNING_CERT);\n        goto f_err;\n    } else if (alg_k & (SSL_kECDHr | SSL_kECDHe)) {\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_ECDH_CERT);\n        goto f_err;\n    }\n#endif\n    pkey = X509_get_pubkey(s->session->peer);\n    pkey_bits = EVP_PKEY_bits(pkey);\n    i = X509_certificate_type(s->session->peer, pkey);\n    EVP_PKEY_free(pkey);\n    if ((alg_a & SSL_aRSA) && !has_bits(i, EVP_PK_RSA | EVP_PKT_SIGN)) {\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n               SSL_R_MISSING_RSA_SIGNING_CERT);\n        goto f_err;\n    }\n#ifndef OPENSSL_NO_DSA\n    else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA | EVP_PKT_SIGN)) {\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n               SSL_R_MISSING_DSA_SIGNING_CERT);\n        goto f_err;\n    }\n#endif\n#ifndef OPENSSL_NO_RSA\n    if (alg_k & (SSL_kRSA | SSL_kRSAPSK)) {\n        if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) &&\n            !has_bits(i, EVP_PK_RSA | EVP_PKT_ENC)) {\n            SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                   SSL_R_MISSING_RSA_ENCRYPTING_CERT);\n            goto f_err;\n        } else if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) {\n            if (pkey_bits <= SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {\n                if (!has_bits(i, EVP_PK_RSA | EVP_PKT_ENC)) {\n                    SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                           SSL_R_MISSING_RSA_ENCRYPTING_CERT);\n                    goto f_err;\n                }\n                if (rsa != NULL) {\n                    al = SSL_AD_INTERNAL_ERROR;\n                    SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR);\n                    goto f_err;\n                }\n            }\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_DH\n    if ((alg_k & SSL_kDHE) && (dh == NULL)) {\n        al = SSL_AD_INTERNAL_ERROR;\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR);\n        goto f_err;\n    } else if ((alg_k & SSL_kDHr) && !SSL_USE_SIGALGS(s) &&\n               !has_bits(i, EVP_PK_DH | EVP_PKS_RSA)) {\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n               SSL_R_MISSING_DH_RSA_CERT);\n        goto f_err;\n    }\n# ifndef OPENSSL_NO_DSA\n    else if ((alg_k & SSL_kDHd) && !SSL_USE_SIGALGS(s) &&\n             !has_bits(i, EVP_PK_DH | EVP_PKS_DSA)) {\n        SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n               SSL_R_MISSING_DH_DSA_CERT);\n        goto f_err;\n    }\n# endif\n#endif\n    if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) &&\n        pkey_bits > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {\n#ifndef OPENSSL_NO_RSA\n        if (alg_k & SSL_kRSA) {\n            if (rsa == NULL) {\n                SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                       SSL_R_MISSING_EXPORT_TMP_RSA_KEY);\n                goto f_err;\n            } else if (RSA_bits(rsa) >\n                SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {\n                al = SSL_AD_EXPORT_RESTRICTION;\n                SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                       SSL_R_MISSING_EXPORT_TMP_RSA_KEY);\n                goto f_err;\n            }\n        } else\n#endif\n#ifndef OPENSSL_NO_DH\n        if (alg_k & SSL_kDHE) {\n            if (DH_bits(dh) >\n                SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {\n                al = SSL_AD_EXPORT_RESTRICTION;\n                SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                       SSL_R_MISSING_EXPORT_TMP_DH_KEY);\n                goto f_err;\n            }\n        } else if (alg_k & (SSL_kDHr | SSL_kDHd)) {\n            al = SSL_AD_EXPORT_RESTRICTION;\n            SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                   SSL_R_MISSING_EXPORT_TMP_DH_KEY);\n                goto f_err;\n        } else\n#endif\n        {\n            SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,\n                   SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE);\n            goto f_err;\n        }\n    }\n    return (1);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n    return (0);\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\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->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_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}']