ssl/statem/statem_lib.c:458: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BUF_reverse`.
Showing all 7 steps of the trace


ssl/statem/statem_lib.c:421:9: Call
419.       }
420.   
421.       j = EVP_PKEY_size(pkey);
               ^
422.       if (((int)len > j) || ((int)PACKET_remaining(pkt) > j)
423.           || (PACKET_remaining(pkt) == 0)) {

crypto/evp/p_lib.c:48:5: Assignment
  46.       if (pkey && pkey->ameth && pkey->ameth->pkey_size)
  47.           return pkey->ameth->pkey_size(pkey);
  48.       return 0;
            ^
  49.   }
  50.   

ssl/statem/statem_lib.c:421:5: Assignment
419.       }
420.   
421.       j = EVP_PKEY_size(pkey);
           ^
422.       if (((int)len > j) || ((int)PACKET_remaining(pkt) > j)
423.           || (PACKET_remaining(pkt) == 0)) {

ssl/statem/statem_lib.c:458:13: Call
456.                   goto err;
457.               }
458.               BUF_reverse(gost_data, data, len);
                   ^
459.               data = gost_data;
460.           }

crypto/buffer/buffer.c:149:1: <LHS trace>
147.   }
148.   
149. > void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)
150.   {
151.       size_t i;

crypto/buffer/buffer.c:149:1: Parameter `size`
  147.   }
  148.   
  149. > void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)
  150.   {
  151.       size_t i;

crypto/buffer/buffer.c:153:9: Binary operation: ([0, +oo] - 1):unsigned64 by call to `BUF_reverse` 
  151.       size_t i;
  152.       if (in) {
  153.           out += size - 1;
                 ^
  154.           for (i = 0; i < size; i++)
  155.               *out-- = *in++;

void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)
{
    size_t i;
    if (in) {
        out += size - 1;
        for (i = 0; i < size; i++)
            *out-- = *in++;
    } else {
        unsigned char *q;
        char c;
        q = out + size - 1;
        for (i = 0; i < size / 2; i++) {
            c = *q;
            *q-- = *out;
            *out++ = c;
        }
    }
}
['MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)\n{\n    EVP_PKEY *pkey = NULL;\n    const unsigned char *data;\n#ifndef OPENSSL_NO_GOST\n    unsigned char *gost_data = NULL;\n#endif\n    MSG_PROCESS_RETURN ret = MSG_PROCESS_ERROR;\n    int j;\n    unsigned int len;\n    X509 *peer;\n    const EVP_MD *md = NULL;\n    size_t hdatalen = 0;\n    void *hdata;\n    unsigned char tls13tbs[TLS13_TBS_PREAMBLE_SIZE + EVP_MAX_MD_SIZE];\n    EVP_MD_CTX *mctx = EVP_MD_CTX_new();\n    EVP_PKEY_CTX *pctx = NULL;\n    if (mctx == NULL) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    peer = s->session->peer;\n    pkey = X509_get0_pubkey(peer);\n    if (pkey == NULL) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    if (ssl_cert_lookup_by_pkey(pkey, NULL) == NULL) {\n        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE);\n        goto err;\n    }\n    if (SSL_USE_SIGALGS(s)) {\n        unsigned int sigalg;\n        if (!PACKET_get_net_2(pkt, &sigalg)) {\n            SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                     SSL_R_BAD_PACKET);\n            goto err;\n        }\n        if (tls12_check_peer_sigalg(s, sigalg, pkey) <= 0) {\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            SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                     ERR_R_INTERNAL_ERROR);\n            goto err;\n    }\n    if (!tls1_lookup_md(s->s3->tmp.peer_sigalg, &md)) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n#ifndef OPENSSL_NO_GOST\n    if (!SSL_USE_SIGALGS(s)\n        && ((PACKET_remaining(pkt) == 64\n             && (EVP_PKEY_id(pkey) == NID_id_GostR3410_2001\n                 || EVP_PKEY_id(pkey) == NID_id_GostR3410_2012_256))\n            || (PACKET_remaining(pkt) == 128\n                && EVP_PKEY_id(pkey) == NID_id_GostR3410_2012_512))) {\n        len = PACKET_remaining(pkt);\n    } else\n#endif\n    if (!PACKET_get_net_2(pkt, &len)) {\n        SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 SSL_R_LENGTH_MISMATCH);\n        goto err;\n    }\n    j = EVP_PKEY_size(pkey);\n    if (((int)len > j) || ((int)PACKET_remaining(pkt) > j)\n        || (PACKET_remaining(pkt) == 0)) {\n        SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 SSL_R_WRONG_SIGNATURE_SIZE);\n        goto err;\n    }\n    if (!PACKET_get_bytes(pkt, &data, len)) {\n        SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 SSL_R_LENGTH_MISMATCH);\n        goto err;\n    }\n    if (!get_cert_verify_tbs_data(s, tls13tbs, &hdata, &hdatalen)) {\n        goto err;\n    }\n#ifdef SSL_DEBUG\n    fprintf(stderr, "Using client verify alg %s\\n", EVP_MD_name(md));\n#endif\n    if (EVP_DigestVerifyInit(mctx, &pctx, md, NULL, pkey) <= 0) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                 ERR_R_EVP_LIB);\n        goto err;\n    }\n#ifndef OPENSSL_NO_GOST\n    {\n        int pktype = EVP_PKEY_id(pkey);\n        if (pktype == NID_id_GostR3410_2001\n            || pktype == NID_id_GostR3410_2012_256\n            || pktype == NID_id_GostR3410_2012_512) {\n            if ((gost_data = OPENSSL_malloc(len)) == NULL) {\n                SSLfatal(s, SSL_AD_INTERNAL_ERROR,\n                         SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            BUF_reverse(gost_data, data, len);\n            data = gost_data;\n        }\n    }\n#endif\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            SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                     ERR_R_EVP_LIB);\n            goto err;\n        }\n    }\n    if (s->version == SSL3_VERSION) {\n        if (EVP_DigestVerifyUpdate(mctx, hdata, hdatalen) <= 0\n                || !EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET,\n                                    (int)s->session->master_key_length,\n                                    s->session->master_key)) {\n            SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                     ERR_R_EVP_LIB);\n            goto err;\n        }\n        if (EVP_DigestVerifyFinal(mctx, data, len) <= 0) {\n            SSLfatal(s, SSL_AD_DECRYPT_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                     SSL_R_BAD_SIGNATURE);\n            goto err;\n        }\n    } else {\n        j = EVP_DigestVerify(mctx, data, len, hdata, hdatalen);\n        if (j <= 0) {\n            SSLfatal(s, SSL_AD_DECRYPT_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY,\n                     SSL_R_BAD_SIGNATURE);\n            goto err;\n        }\n    }\n    ret = MSG_PROCESS_CONTINUE_READING;\n err:\n    BIO_free(s->s3->handshake_buffer);\n    s->s3->handshake_buffer = NULL;\n    EVP_MD_CTX_free(mctx);\n#ifndef OPENSSL_NO_GOST\n    OPENSSL_free(gost_data);\n#endif\n    return ret;\n}', 'int EVP_PKEY_size(EVP_PKEY *pkey)\n{\n    if (pkey && pkey->ameth && pkey->ameth->pkey_size)\n        return pkey->ameth->pkey_size(pkey);\n    return 0;\n}', 'void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)\n{\n    size_t i;\n    if (in) {\n        out += size - 1;\n        for (i = 0; i < size; i++)\n            *out-- = *in++;\n    } else {\n        unsigned char *q;\n        char c;\n        q = out + size - 1;\n        for (i = 0; i < size / 2; i++) {\n            c = *q;\n            *q-- = *out;\n            *out++ = c;\n        }\n    }\n}']