test/ectest.c:1590: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_dup`.
Showing all 10 steps of the trace


test/ectest.c:1586:13: Call
1584.           || !TEST_ptr(group_gen = EC_GROUP_get0_generator(group))
1585.           || !TEST_ptr(group_order = EC_GROUP_get0_order(group))
1586.           || !TEST_true(EC_GROUP_get_cofactor(group, group_cofactor, NULL))
                    ^
1587.           || !TEST_true(EC_GROUP_get_curve(group, group_p, group_a, group_b, NULL))
1588.           || !TEST_ptr(other_gen = EC_POINT_dup(group_gen, group))

crypto/ec/ec_lib.c:342:1: Parameter `cofactor->d`
  340.   }
  341.   
  342. > int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
  343.                             BN_CTX *ctx)
  344.   {

test/ectest.c:1590:13: Call
1588.           || !TEST_ptr(other_gen = EC_POINT_dup(group_gen, group))
1589.           || !TEST_true(EC_POINT_add(group, other_gen, group_gen, group_gen, NULL))
1590.           || !TEST_ptr(other_order = BN_dup(group_order))
                    ^
1591.           || !TEST_true(BN_add_word(other_order, 1))
1592.           || !TEST_ptr(other_a = BN_dup(group_a))

crypto/bn/bn_lib.c:262:1: Parameter `*a->d`
  260.   }
  261.   
  262. > BIGNUM *BN_dup(const BIGNUM *a)
  263.   {
  264.       BIGNUM *t;

crypto/bn/bn_lib.c:273:10: Call
  271.       if (t == NULL)
  272.           return NULL;
  273.       if (!BN_copy(t, a)) {
                  ^
  274.           BN_free(t);
  275.           return NULL;

crypto/bn/bn_lib.c:281:1: <Offset trace>
279.   }
280.   
281. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
282.   {
283.       bn_check_top(b);

crypto/bn/bn_lib.c:281:1: Parameter `b->top`
    279.   }
    280.   
    281. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
    282.   {
    283.       bn_check_top(b);

crypto/bn/bn_lib.c:281:1: <Length trace>
279.   }
280.   
281. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
282.   {
283.       bn_check_top(b);

crypto/bn/bn_lib.c:281:1: Parameter `*b->d`
    279.   }
    280.   
    281. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
    282.   {
    283.       bn_check_top(b);

crypto/bn/bn_lib.c:291:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_dup` 
    289.   
    290.       if (b->top > 0)
    291.           memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
                   ^
    292.   
    293.       a->neg = b->neg;

BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
{
    bn_check_top(b);
    if (a == b)
        return a;
    if (bn_wexpand(a, b->top) == NULL)
        return NULL;
    if (b->top > 0)
        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
    a->neg = b->neg;
    a->top = b->top;
    a->flags |= b->flags & BN_FLG_FIXED_TOP;
    bn_check_top(a);
    return a;
}
['static int check_named_curve(int id)\n{\n    int ret = 0, nid, field_nid, has_seed, rv = 0;\n    EC_GROUP *group = NULL, *gtest = NULL, *galias = NULL;\n    const EC_POINT *group_gen = NULL;\n    EC_POINT *other_gen = NULL;\n    BIGNUM *group_p = NULL, *group_a = NULL, *group_b = NULL;\n    BIGNUM *other_p = NULL, *other_a = NULL, *other_b = NULL;\n    BIGNUM *group_cofactor = NULL, *other_cofactor = NULL;\n    BIGNUM *other_order = NULL;\n    const BIGNUM *group_order = NULL;\n    BN_CTX *bn_ctx = NULL;\n    static const unsigned char invalid_seed[] = "THIS IS NOT A VALID SEED";\n    static size_t invalid_seed_len = sizeof(invalid_seed);\n    nid = curves[id].nid;\n    if (!TEST_ptr(bn_ctx = BN_CTX_new())\n        || !TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))\n        || !TEST_ptr(gtest = EC_GROUP_dup(group))\n        || !TEST_ptr(group_p = BN_new())\n        || !TEST_ptr(group_a = BN_new())\n        || !TEST_ptr(group_b = BN_new())\n        || !TEST_ptr(group_cofactor = BN_new())\n        || !TEST_ptr(group_gen = EC_GROUP_get0_generator(group))\n        || !TEST_ptr(group_order = EC_GROUP_get0_order(group))\n        || !TEST_true(EC_GROUP_get_cofactor(group, group_cofactor, NULL))\n        || !TEST_true(EC_GROUP_get_curve(group, group_p, group_a, group_b, NULL))\n        || !TEST_ptr(other_gen = EC_POINT_dup(group_gen, group))\n        || !TEST_true(EC_POINT_add(group, other_gen, group_gen, group_gen, NULL))\n        || !TEST_ptr(other_order = BN_dup(group_order))\n        || !TEST_true(BN_add_word(other_order, 1))\n        || !TEST_ptr(other_a = BN_dup(group_a))\n        || !TEST_true(BN_add_word(other_a, 1))\n        || !TEST_ptr(other_b = BN_dup(group_b))\n        || !TEST_true(BN_add_word(other_b, 1))\n        || !TEST_ptr(other_cofactor = BN_dup(group_cofactor))\n        || !TEST_true(BN_add_word(other_cofactor, 1)))\n        goto err;\n    has_seed = (EC_GROUP_get_seed_len(group) > 0);\n    field_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group));\n    if (field_nid == NID_X9_62_characteristic_two_field) {\n        if (!TEST_ptr(other_p = BN_dup(group_p))\n            || !TEST_true(BN_lshift1(other_p, other_p)))\n            goto err;\n    } else {\n        if (!TEST_ptr(other_p = BN_dup(group_p)))\n            goto err;\n        if (!TEST_ptr(BN_copy(other_p,\n                              BN_ucmp(BN_get0_nist_prime_192(), other_p) == 0 ?\n                                      BN_get0_nist_prime_256() :\n                                      BN_get0_nist_prime_192())))\n            goto err;\n    }\n    if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0), nid)\n\t|| !TEST_int_eq(EC_GROUP_check_named_curve(group, 1),\n                        EC_curve_nid2nist(nid) != NULL ? nid : NID_undef))\n        goto err;\n    EC_GROUP_set_curve_name(group, NID_undef);\n    if (!TEST_int_gt(rv = EC_GROUP_check_named_curve(group, 0), 0))\n        goto err;\n#if 0\n    if (rv != nid) {\n        if (!TEST_ptr(galias = EC_GROUP_new_by_curve_name(rv)))\n            goto err;\n        EC_GROUP_set_curve_name(galias, nid);\n        if (!TEST_int_eq(EC_GROUP_check_named_curve(galias, 0), nid))\n            goto err;\n    }\n#endif\n    EC_GROUP_set_curve_name(group, nid + 1);\n    if (!TEST_int_le(EC_GROUP_check_named_curve(group, 0), 0))\n        goto err;\n    EC_GROUP_set_curve_name(group, nid);\n    if (!TEST_int_eq(EC_GROUP_set_seed(group, invalid_seed, invalid_seed_len),\n                     invalid_seed_len))\n        goto err;\n    if (has_seed) {\n        if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0), 0))\n            goto err;\n    } else {\n        if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0), nid))\n            goto err;\n    }\n    if (!TEST_int_eq(EC_GROUP_set_seed(group, NULL, 0), 1)\n        || !TEST_int_gt(EC_GROUP_check_named_curve(group, 0), 0))\n        goto err;\n    if (!TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), nid))\n        goto err;\n    if (!TEST_true(EC_GROUP_set_generator(gtest, other_gen, group_order,\n                                          group_cofactor))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_generator(gtest, group_gen, other_order,\n                                             group_cofactor))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_generator(gtest, group_gen, NULL,\n                                             group_cofactor))\n        || !TEST_int_le(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_generator(gtest, group_gen, group_order,\n                                             other_cofactor))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_generator(gtest, group_gen, group_order,\n                                             NULL))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), nid)\n        || !TEST_true(EC_GROUP_set_generator(gtest, group_gen, group_order,\n                                             group_cofactor))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), nid)\n        || !TEST_true(EC_GROUP_set_curve(gtest, other_p, group_a, group_b, NULL))\n        || !TEST_int_le(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_curve(gtest, group_p, other_a, group_b, NULL))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_curve(gtest, group_p, group_a, other_b, NULL))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), 0)\n        || !TEST_true(EC_GROUP_set_curve(gtest, group_p, group_a, group_b, NULL))\n        || !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0), nid))\n        goto err;\n    ret = 1;\nerr:\n    BN_free(group_p);\n    BN_free(other_p);\n    BN_free(group_a);\n    BN_free(other_a);\n    BN_free(group_b);\n    BN_free(other_b);\n    BN_free(group_cofactor);\n    BN_free(other_cofactor);\n    BN_free(other_order);\n    EC_POINT_free(other_gen);\n    EC_GROUP_free(galias);\n    EC_GROUP_free(gtest);\n    EC_GROUP_free(group);\n    BN_CTX_free(bn_ctx);\n    return ret;\n}', 'int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx)\n{\n    if (group->cofactor == NULL)\n        return 0;\n    if (!BN_copy(cofactor, group->cofactor))\n        return 0;\n    return !BN_is_zero(group->cofactor);\n}', 'BIGNUM *BN_dup(const BIGNUM *a)\n{\n    BIGNUM *t;\n    if (a == NULL)\n        return NULL;\n    bn_check_top(a);\n    t = BN_get_flags(a, BN_FLG_SECURE) ? BN_secure_new() : BN_new();\n    if (t == NULL)\n        return NULL;\n    if (!BN_copy(t, a)) {\n        BN_free(t);\n        return NULL;\n    }\n    bn_check_top(t);\n    return t;\n}', 'BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n{\n    bn_check_top(b);\n    if (a == b)\n        return a;\n    if (bn_wexpand(a, b->top) == NULL)\n        return NULL;\n    if (b->top > 0)\n        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);\n    a->neg = b->neg;\n    a->top = b->top;\n    a->flags |= b->flags & BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return a;\n}']