test/ectest.c:1893: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_add`.
Showing all 13 steps of the trace


test/ectest.c:1871:14: Call
1869.       if (!(TEST_ptr(x = BN_new())
1870.             && TEST_ptr(y = BN_new())
1871.             && TEST_ptr(key = EC_KEY_new_by_curve_name(curves[id].nid))
                     ^
1872.             && TEST_ptr(group = EC_KEY_get0_group(key))
1873.             && TEST_ptr(meth = EC_GROUP_method_of(group))

crypto/ec/ec_key.c:25:19: Call
  23.   EC_KEY *EC_KEY_new_by_curve_name(int nid)
  24.   {
  25.       EC_KEY *ret = EC_KEY_new();
                          ^
  26.       if (ret == NULL)
  27.           return NULL;

crypto/ec/ec_key.c:20:12: Call
    18.   EC_KEY *EC_KEY_new(void)
    19.   {
    20.       return EC_KEY_new_method(NULL);
                     ^
    21.   }
    22.   

crypto/ec/ec_kmeth.c:123:5: Call
      121.   
      122.    err:
      123.       EC_KEY_free(ret);
                 ^
      124.       return NULL;
      125.   }

crypto/ec/ec_key.c:41:1: Parameter `r->priv_key->d`
        39.   }
        40.   
        41. > void EC_KEY_free(EC_KEY *r)
        42.   {
        43.       int i;

test/ectest.c:1893:14: Call
1891.       } else if (type == NID_X9_62_prime_field) {
1892.           /* test for prime curves */
1893.           if (!TEST_true(BN_add(x, x, field)))
                     ^
1894.               goto err;
1895.       } else {

crypto/bn/bn_add.c:14:1: Parameter `*r->d`
  12.   
  13.   /* signed add of b to a. */
  14. > int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
  15.   {
  16.       int ret, r_neg, cmp_res;

crypto/bn/bn_add.c:34:13: Call
  32.           } else {
  33.               r_neg = 0;
  34.               BN_zero(r);
                    ^
  35.               ret = 1;
  36.           }

crypto/bn/bn_lib.c:361:1: <Length trace>
359.   }
360.   
361. > int BN_set_word(BIGNUM *a, BN_ULONG w)
362.   {
363.       bn_check_top(a);

crypto/bn/bn_lib.c:361:1: Parameter `*a->d`
    359.   }
    360.   
    361. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    362.   {
    363.       bn_check_top(a);

crypto/bn/bn_lib.c:364:9: Call
    362.   {
    363.       bn_check_top(a);
    364.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    365.           return 0;
    366.       a->neg = 0;

crypto/bn/bn_lcl.h:660:1: Parameter `*a->d`
      658.                            const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
      659.   
      660. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
      661.   {
      662.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/bn/bn_lib.c:367:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_add` 
    365.           return 0;
    366.       a->neg = 0;
    367.       a->d[0] = w;
               ^
    368.       a->top = (w ? 1 : 0);
    369.       a->flags &= ~BN_FLG_FIXED_TOP;

int BN_set_word(BIGNUM *a, BN_ULONG w)
{
    bn_check_top(a);
    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
        return 0;
    a->neg = 0;
    a->d[0] = w;
    a->top = (w ? 1 : 0);
    a->flags &= ~BN_FLG_FIXED_TOP;
    bn_check_top(a);
    return 1;
}
['static int check_ec_key_field_public_range_test(int id)\n{\n    int ret = 0, type = 0;\n    const EC_POINT *pub = NULL;\n    const EC_GROUP *group = NULL;\n    const EC_METHOD *meth = NULL;\n    const BIGNUM *field = NULL;\n    BIGNUM *x = NULL, *y = NULL;\n    EC_KEY *key = NULL;\n    if (!(TEST_ptr(x = BN_new())\n          && TEST_ptr(y = BN_new())\n          && TEST_ptr(key = EC_KEY_new_by_curve_name(curves[id].nid))\n          && TEST_ptr(group = EC_KEY_get0_group(key))\n          && TEST_ptr(meth = EC_GROUP_method_of(group))\n          && TEST_ptr(field = EC_GROUP_get0_field(group))\n          && TEST_int_gt(EC_KEY_generate_key(key), 0)\n          && TEST_int_gt(EC_KEY_check_key(key), 0)\n          && TEST_ptr(pub = EC_KEY_get0_public_key(key))\n          && TEST_int_gt(EC_POINT_get_affine_coordinates(group, pub, x, y,\n                                                         NULL), 0)))\n        goto err;\n    type = EC_METHOD_get_field_type(meth);\n    if (type == NID_X9_62_characteristic_two_field) {\n        if (!TEST_true(BN_GF2m_add(x, x, field)))\n            goto err;\n    } else if (type == NID_X9_62_prime_field) {\n        if (!TEST_true(BN_add(x, x, field)))\n            goto err;\n    } else {\n        TEST_error("Unsupported EC_METHOD field_type");\n        goto err;\n    }\n    if (!TEST_int_le(EC_KEY_set_public_key_affine_coordinates(key, x, y), 0))\n        goto err;\n    ret = 1;\nerr:\n    BN_free(x);\n    BN_free(y);\n    EC_KEY_free(key);\n    return ret;\n}', 'EC_KEY *EC_KEY_new_by_curve_name(int nid)\n{\n    EC_KEY *ret = EC_KEY_new();\n    if (ret == NULL)\n        return NULL;\n    ret->group = EC_GROUP_new_by_curve_name(nid);\n    if (ret->group == NULL) {\n        EC_KEY_free(ret);\n        return NULL;\n    }\n    if (ret->meth->set_group != NULL\n        && ret->meth->set_group(ret, ret->group) == 0) {\n        EC_KEY_free(ret);\n        return NULL;\n    }\n    return ret;\n}', 'EC_KEY *EC_KEY_new(void)\n{\n    return EC_KEY_new_method(NULL);\n}', 'EC_KEY *EC_KEY_new_method(ENGINE *engine)\n{\n    EC_KEY *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->references = 1;\n    ret->lock = CRYPTO_THREAD_lock_new();\n    if (ret->lock == NULL) {\n        ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    ret->meth = EC_KEY_get_default_method();\n#ifndef OPENSSL_NO_ENGINE\n    if (engine != NULL) {\n        if (!ENGINE_init(engine)) {\n            ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);\n            goto err;\n        }\n        ret->engine = engine;\n    } else\n        ret->engine = ENGINE_get_default_EC();\n    if (ret->engine != NULL) {\n        ret->meth = ENGINE_get_EC(ret->engine);\n        if (ret->meth == NULL) {\n            ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);\n            goto err;\n        }\n    }\n#endif\n    ret->version = 1;\n    ret->conv_form = POINT_CONVERSION_UNCOMPRESSED;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_EC_KEY, ret, &ret->ex_data)) {\n        goto err;\n    }\n    if (ret->meth->init != NULL && ret->meth->init(ret) == 0) {\n        ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_INIT_FAIL);\n        goto err;\n    }\n    return ret;\n err:\n    EC_KEY_free(ret);\n    return NULL;\n}', 'void EC_KEY_free(EC_KEY *r)\n{\n    int i;\n    if (r == NULL)\n        return;\n    CRYPTO_DOWN_REF(&r->references, &i, r->lock);\n    REF_PRINT_COUNT("EC_KEY", r);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    if (r->meth != NULL && r->meth->finish != NULL)\n        r->meth->finish(r);\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(r->engine);\n#endif\n    if (r->group && r->group->meth->keyfinish)\n        r->group->meth->keyfinish(r);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_EC_KEY, r, &r->ex_data);\n    CRYPTO_THREAD_lock_free(r->lock);\n    EC_GROUP_free(r->group);\n    EC_POINT_free(r->pub_key);\n    BN_clear_free(r->priv_key);\n    OPENSSL_clear_free((void *)r, sizeof(EC_KEY));\n}', 'int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int ret, r_neg, cmp_res;\n    bn_check_top(a);\n    bn_check_top(b);\n    if (a->neg == b->neg) {\n        r_neg = a->neg;\n        ret = BN_uadd(r, a, b);\n    } else {\n        cmp_res = BN_ucmp(a, b);\n        if (cmp_res > 0) {\n            r_neg = a->neg;\n            ret = BN_usub(r, a, b);\n        } else if (cmp_res < 0) {\n            r_neg = b->neg;\n            ret = BN_usub(r, b, a);\n        } else {\n            r_neg = 0;\n            BN_zero(r);\n            ret = 1;\n        }\n    }\n    r->neg = r_neg;\n    bn_check_top(r);\n    return ret;\n}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return 0;\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    a->flags &= ~BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return 1;\n}', 'static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)\n{\n    if (bits > (INT_MAX - BN_BITS2 + 1))\n        return NULL;\n    if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)\n        return a;\n    return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);\n}']