ssl/statem/statem_clnt.c:1277: 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:1021:1: Parameter `s->ctx->sessions->num_items`
1019.   }
1020.   
1021. > MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
1022.   {
1023.       STACK_OF(SSL_CIPHER) *sk;

ssl/statem/statem_clnt.c:1277:5: Call
1275.       return MSG_PROCESS_CONTINUE_READING;
1276.    f_err:
1277.       ssl3_send_alert(s, SSL3_AL_FATAL, al);
            ^
1278.    err:
1279.       ossl_statem_set_error(s);

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:785:1: Parameter `ctx->sessions->num_items`
    783.   }
    784.   
    785. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    786.   {
    787.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:787:12: Call
    785.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    786.   {
    787.       return remove_session_lock(ctx, c, 1);
                      ^
    788.   }
    789.   

ssl/ssl_sess.c:790:1: Parameter `ctx->sessions->num_items`
      788.   }
      789.   
      790. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
      791.   {
      792.       SSL_SESSION *r;

ssl/ssl_sess.c:800:17: Call
      798.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
      799.               ret = 1;
      800.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                             ^
      801.               SSL_SESSION_list_remove(ctx, c);
      802.           }

ssl/ssl_locl.h:697:1: Parameter `lh->num_items`
        695.   
        696.   DEFINE_STACK_OF(SSL_COMP)
        697. > DEFINE_LHASH_OF(SSL_SESSION);
        698.   
        699.   

ssl/ssl_locl.h:697:1: Call
        695.   
        696.   DEFINE_STACK_OF(SSL_COMP)
        697. > DEFINE_LHASH_OF(SSL_SESSION);
        698.   
        699.   

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);
}
['MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)\n{\n    STACK_OF(SSL_CIPHER) *sk;\n    const SSL_CIPHER *c;\n    PACKET session_id;\n    size_t session_id_len;\n    unsigned char *cipherchars;\n    int i, al = SSL_AD_INTERNAL_ERROR;\n    unsigned int compression;\n    unsigned int sversion;\n    int protverr;\n#ifndef OPENSSL_NO_COMP\n    SSL_COMP *comp;\n#endif\n    if (!PACKET_get_net_2(pkt, &sversion)) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n    protverr = ssl_choose_client_version(s, sversion);\n    if (protverr != 0) {\n        al = SSL_AD_PROTOCOL_VERSION;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, protverr);\n        goto f_err;\n    }\n    if (!PACKET_copy_bytes(pkt, s->s3->server_random, SSL3_RANDOM_SIZE)) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n    s->hit = 0;\n    if (!PACKET_get_length_prefixed_1(pkt, &session_id)) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n    session_id_len = PACKET_remaining(&session_id);\n    if (session_id_len > sizeof s->session->session_id\n        || session_id_len > SSL3_SESSION_ID_SIZE) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG);\n        goto f_err;\n    }\n    if (!PACKET_get_bytes(pkt, &cipherchars, TLS_CIPHER_LEN)) {\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);\n        al = SSL_AD_DECODE_ERROR;\n        goto f_err;\n    }\n    if (s->version >= TLS1_VERSION && s->tls_session_secret_cb &&\n        s->session->tlsext_tick) {\n        const SSL_CIPHER *pref_cipher = NULL;\n        s->session->master_key_length = sizeof(s->session->master_key);\n        if (s->tls_session_secret_cb(s, s->session->master_key,\n                                     &s->session->master_key_length,\n                                     NULL, &pref_cipher,\n                                     s->tls_session_secret_cb_arg)) {\n            s->session->cipher = pref_cipher ?\n                pref_cipher : ssl_get_cipher_by_char(s, cipherchars);\n        } else {\n            SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, ERR_R_INTERNAL_ERROR);\n            al = SSL_AD_INTERNAL_ERROR;\n            goto f_err;\n        }\n    }\n    if (session_id_len != 0 && session_id_len == s->session->session_id_length\n        && memcmp(PACKET_data(&session_id), s->session->session_id,\n                  session_id_len) == 0) {\n        if (s->sid_ctx_length != s->session->sid_ctx_length\n            || memcmp(s->session->sid_ctx, s->sid_ctx, s->sid_ctx_length)) {\n            al = SSL_AD_ILLEGAL_PARAMETER;\n            SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO,\n                   SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);\n            goto f_err;\n        }\n        s->hit = 1;\n    } else {\n        if (s->session->session_id_length > 0) {\n            if (!ssl_get_new_session(s, 0)) {\n                goto f_err;\n            }\n        }\n        s->session->session_id_length = session_id_len;\n        memcpy(s->session->session_id, PACKET_data(&session_id),\n               session_id_len);\n    }\n    c = ssl_get_cipher_by_char(s, cipherchars);\n    if (c == NULL) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_UNKNOWN_CIPHER_RETURNED);\n        goto f_err;\n    }\n    if (!SSL_USE_TLS1_2_CIPHERS(s))\n        s->s3->tmp.mask_ssl = SSL_TLSV1_2;\n    else\n        s->s3->tmp.mask_ssl = 0;\n    if ((c->algorithm_ssl & SSL_TLSV1) && s->version == SSL3_VERSION)\n        s->s3->tmp.mask_ssl |= SSL_TLSV1;\n    if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK)) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED);\n        goto f_err;\n    }\n    sk = ssl_get_ciphers_by_id(s);\n    i = sk_SSL_CIPHER_find(sk, c);\n    if (i < 0) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED);\n        goto f_err;\n    }\n    if (s->session->cipher)\n        s->session->cipher_id = s->session->cipher->id;\n    if (s->hit && (s->session->cipher_id != c->id)) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO,\n               SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED);\n        goto f_err;\n    }\n    s->s3->tmp.new_cipher = c;\n    if (!PACKET_get_1(pkt, &compression)) {\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH);\n        al = SSL_AD_DECODE_ERROR;\n        goto f_err;\n    }\n#ifdef OPENSSL_NO_COMP\n    if (compression != 0) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO,\n               SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);\n        goto f_err;\n    }\n    if (s->session->compress_meth != 0) {\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_INCONSISTENT_COMPRESSION);\n        goto f_err;\n    }\n#else\n    if (s->hit && compression != s->session->compress_meth) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO,\n               SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED);\n        goto f_err;\n    }\n    if (compression == 0)\n        comp = NULL;\n    else if (!ssl_allow_compression(s)) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_COMPRESSION_DISABLED);\n        goto f_err;\n    } else {\n        comp = ssl3_comp_find(s->ctx->comp_methods, compression);\n    }\n    if (compression != 0 && comp == NULL) {\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO,\n               SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM);\n        goto f_err;\n    } else {\n        s->s3->tmp.new_compression = comp;\n    }\n#endif\n    if (!ssl_parse_serverhello_tlsext(s, pkt)) {\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_PARSE_TLSEXT);\n        goto err;\n    }\n    if (PACKET_remaining(pkt) != 0) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_BAD_PACKET_LENGTH);\n        goto f_err;\n    }\n#ifndef OPENSSL_NO_SCTP\n    if (SSL_IS_DTLS(s) && s->hit) {\n        unsigned char sctpauthkey[64];\n        char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)];\n        memcpy(labelbuffer, DTLS1_SCTP_AUTH_LABEL,\n               sizeof(DTLS1_SCTP_AUTH_LABEL));\n        if (SSL_export_keying_material(s, sctpauthkey,\n                                   sizeof(sctpauthkey),\n                                   labelbuffer,\n                                   sizeof(labelbuffer), NULL, 0,\n                                   0) <= 0)\n            goto err;\n        BIO_ctrl(SSL_get_wbio(s),\n                 BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY,\n                 sizeof(sctpauthkey), sctpauthkey);\n    }\n#endif\n    return MSG_PROCESS_CONTINUE_READING;\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    ossl_statem_set_error(s);\n    return MSG_PROCESS_ERROR;\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}', 'DEFINE_LHASH_OF(SSL_SESSION)', '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}']