ssl/statem/statem_clnt.c:2075: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: 29 by call to `tls1_check_curve`.
Showing all 9 steps of the trace


ssl/statem/statem_clnt.c:2052:1: Parameter `*pkt->curr`
2050.   }
2051.   
2052. > static int tls_process_ske_ecdhe(SSL *s, PACKET *pkt, EVP_PKEY **pkey, int *al)
2053.   {
2054.   #ifndef OPENSSL_NO_EC

ssl/statem/statem_clnt.c:2075:10: Call
2073.        * invalid curve. ECParameters is 3 bytes.
2074.        */
2075.       if (!tls1_check_curve(s, ecparams, 3)) {
                 ^
2076.           *al = SSL_AD_ILLEGAL_PARAMETER;
2077.           SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, SSL_R_WRONG_CURVE);

ssl/t1_lib.c:176:1: Array declaration
  174.   
  175.   /* The default curves */
  176. > static const unsigned char eccurves_default[] = {
  177.       0, 29,                      /* X25519 (29) */
  178.       0, 23,                      /* secp256r1 (23) */

ssl/t1_lib.c:309:20: Call
  307.       for (i = 0; i < num_curves; i++, curves += 2) {
  308.           if (p[1] == curves[0] && p[2] == curves[1])
  309.               return tls_curve_allowed(s, p + 1, SSL_SECOP_CURVE_CHECK);
                            ^
  310.       }
  311.       return 0;

ssl/t1_lib.c:268:1: <Offset trace>
266.   
267.   /* See if curve is allowed by security callback */
268. > int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)
269.   {
270.       const tls_curve_info *cinfo;

ssl/t1_lib.c:268:1: Parameter `*curve`
    266.   
    267.   /* See if curve is allowed by security callback */
    268. > int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)
    269.   {
    270.       const tls_curve_info *cinfo;

ssl/t1_lib.c:137:1: <Length trace>
135.    * table: the index of each entry is one less than the TLS curve id.
136.    */
137. > static const tls_curve_info nid_list[] = {
138.       {NID_sect163k1, 80, TLS_CURVE_CHAR2}, /* sect163k1 (1) */
139.       {NID_sect163r1, 80, TLS_CURVE_CHAR2}, /* sect163r1 (2) */

ssl/t1_lib.c:137:1: Array declaration
    135.    * table: the index of each entry is one less than the TLS curve id.
    136.    */
    137. > static const tls_curve_info nid_list[] = {
    138.       {NID_sect163k1, 80, TLS_CURVE_CHAR2}, /* sect163k1 (1) */
    139.       {NID_sect163r1, 80, TLS_CURVE_CHAR2}, /* sect163r1 (2) */

ssl/t1_lib.c:275:5: Array access: Offset: [-1, +oo] Size: 29 by call to `tls1_check_curve` 
    273.       if ((curve[1] < 1) || ((size_t)curve[1] > OSSL_NELEM(nid_list)))
    274.           return 0;
    275.       cinfo = &nid_list[curve[1] - 1];
               ^
    276.   # ifdef OPENSSL_NO_EC2M
    277.       if (cinfo->flags & TLS_CURVE_CHAR2)

int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)
{
    const tls_curve_info *cinfo;
    if (curve[0])
        return 1;
    if ((curve[1] < 1) || ((size_t)curve[1] > OSSL_NELEM(nid_list)))
        return 0;
    cinfo = &nid_list[curve[1] - 1];
# ifdef OPENSSL_NO_EC2M
    if (cinfo->flags & TLS_CURVE_CHAR2)
        return 0;
# endif
    return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)curve);
}
['static int tls_process_ske_ecdhe(SSL *s, PACKET *pkt, EVP_PKEY **pkey, int *al)\n{\n#ifndef OPENSSL_NO_EC\n    PACKET encoded_pt;\n    const unsigned char *ecparams;\n    int curve_nid;\n    unsigned int curve_flags;\n    EVP_PKEY_CTX *pctx = NULL;\n    if (!PACKET_get_bytes(pkt, &ecparams, 3)) {\n        *al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, SSL_R_LENGTH_TOO_SHORT);\n        return 0;\n    }\n    if (!tls1_check_curve(s, ecparams, 3)) {\n        *al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, SSL_R_WRONG_CURVE);\n        return 0;\n    }\n    curve_nid = tls1_ec_curve_id2nid(*(ecparams + 2), &curve_flags);\n    if (curve_nid == 0) {\n        *al = SSL_AD_INTERNAL_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE,\n               SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS);\n        return 0;\n    }\n    if ((curve_flags & TLS_CURVE_TYPE) == TLS_CURVE_CUSTOM) {\n        EVP_PKEY *key = EVP_PKEY_new();\n        if (key == NULL || !EVP_PKEY_set_type(key, curve_nid)) {\n            *al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, ERR_R_EVP_LIB);\n            EVP_PKEY_free(key);\n            return 0;\n        }\n        s->s3->peer_tmp = key;\n    } else {\n        pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);\n        if (pctx == NULL\n            || EVP_PKEY_paramgen_init(pctx) <= 0\n            || EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, curve_nid) <= 0\n            || EVP_PKEY_paramgen(pctx, &s->s3->peer_tmp) <= 0) {\n            *al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, ERR_R_EVP_LIB);\n            EVP_PKEY_CTX_free(pctx);\n            return 0;\n        }\n        EVP_PKEY_CTX_free(pctx);\n        pctx = NULL;\n    }\n    if (!PACKET_get_length_prefixed_1(pkt, &encoded_pt)) {\n        *al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, SSL_R_LENGTH_MISMATCH);\n        return 0;\n    }\n    if (!EVP_PKEY_set1_tls_encodedpoint(s->s3->peer_tmp,\n                                        PACKET_data(&encoded_pt),\n                                        PACKET_remaining(&encoded_pt))) {\n        *al = SSL_AD_ILLEGAL_PARAMETER;\n        SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, SSL_R_BAD_ECPOINT);\n        return 0;\n    }\n    if (s->s3->tmp.new_cipher->algorithm_auth & SSL_aECDSA)\n        *pkey = X509_get0_pubkey(s->session->peer);\n    else if (s->s3->tmp.new_cipher->algorithm_auth & SSL_aRSA)\n        *pkey = X509_get0_pubkey(s->session->peer);\n    return 1;\n#else\n    SSLerr(SSL_F_TLS_PROCESS_SKE_ECDHE, ERR_R_INTERNAL_ERROR);\n    *al = SSL_AD_INTERNAL_ERROR;\n    return 0;\n#endif\n}', 'int tls1_check_curve(SSL *s, const unsigned char *p, size_t len)\n{\n    const unsigned char *curves;\n    size_t num_curves, i;\n    unsigned int suiteb_flags = tls1_suiteb(s);\n    if (len != 3 || p[0] != NAMED_CURVE_TYPE)\n        return 0;\n    if (suiteb_flags) {\n        unsigned long cid = s->s3->tmp.new_cipher->id;\n        if (p[1])\n            return 0;\n        if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) {\n            if (p[2] != TLSEXT_curve_P_256)\n                return 0;\n        } else if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384) {\n            if (p[2] != TLSEXT_curve_P_384)\n                return 0;\n        } else\n            return 0;\n    }\n    if (!tls1_get_curvelist(s, 0, &curves, &num_curves))\n        return 0;\n    for (i = 0; i < num_curves; i++, curves += 2) {\n        if (p[1] == curves[0] && p[2] == curves[1])\n            return tls_curve_allowed(s, p + 1, SSL_SECOP_CURVE_CHECK);\n    }\n    return 0;\n}', 'int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)\n{\n    const tls_curve_info *cinfo;\n    if (curve[0])\n        return 1;\n    if ((curve[1] < 1) || ((size_t)curve[1] > OSSL_NELEM(nid_list)))\n        return 0;\n    cinfo = &nid_list[curve[1] - 1];\n# ifdef OPENSSL_NO_EC2M\n    if (cinfo->flags & TLS_CURVE_CHAR2)\n        return 0;\n# endif\n    return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)curve);\n}']