test/ectest.c:1591: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_add_word`.
Showing all 8 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:1591:13: Call
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))
1593.           || !TEST_true(BN_add_word(other_a, 1))

crypto/bn/bn_word.c:98:1: Parameter `*a->d`
  96.   }
  97.   
  98. > int BN_add_word(BIGNUM *a, BN_ULONG w)
  99.   {
  100.       BN_ULONG l;

crypto/bn/bn_word.c:115:13: Call
  113.       if (a->neg) {
  114.           a->neg = 0;
  115.           i = BN_sub_word(a, w);
                     ^
  116.           if (!BN_is_zero(a))
  117.               a->neg = !(a->neg);

crypto/bn/bn_word.c:134:1: <Length trace>
132.   }
133.   
134. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
135.   {
136.       int i;

crypto/bn/bn_word.c:134:1: Parameter `*a->d`
    132.   }
    133.   
    134. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
    135.   {
    136.       int i;

crypto/bn/bn_word.c:159:27: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_add_word` 
    157.       }
    158.   
    159.       if ((a->top == 1) && (a->d[0] < w)) {
                                     ^
    160.           a->d[0] = w - a->d[0];
    161.           a->neg = 1;

int BN_sub_word(BIGNUM *a, BN_ULONG w)
{
    int i;
    bn_check_top(a);
    w &= BN_MASK2;
    if (!w)
        return 1;
    if (BN_is_zero(a)) {
        i = BN_set_word(a, w);
        if (i != 0)
            BN_set_negative(a, 1);
        return i;
    }
    if (a->neg) {
        a->neg = 0;
        i = BN_add_word(a, w);
        a->neg = 1;
        return i;
    }
    if ((a->top == 1) && (a->d[0] < w)) {
        a->d[0] = w - a->d[0];
        a->neg = 1;
        return 1;
    }
    i = 0;
    for (;;) {
        if (a->d[i] >= w) {
            a->d[i] -= w;
            break;
        } else {
            a->d[i] = (a->d[i] - w) & BN_MASK2;
            i++;
            w = 1;
        }
    }
    if ((a->d[i] == 0) && (i == (a->top - 1)))
        a->top--;
    bn_check_top(a);
    return 1;
}
['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}', 'int BN_add_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG l;\n    int i;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return 1;\n    if (BN_is_zero(a))\n        return BN_set_word(a, w);\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_sub_word(a, w);\n        if (!BN_is_zero(a))\n            a->neg = !(a->neg);\n        return i;\n    }\n    for (i = 0; w != 0 && i < a->top; i++) {\n        a->d[i] = l = (a->d[i] + w) & BN_MASK2;\n        w = (w > l) ? 1 : 0;\n    }\n    if (w && i == a->top) {\n        if (bn_wexpand(a, a->top + 1) == NULL)\n            return 0;\n        a->top++;\n        a->d[i] = w;\n    }\n    bn_check_top(a);\n    return 1;\n}', 'int BN_sub_word(BIGNUM *a, BN_ULONG w)\n{\n    int i;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return 1;\n    if (BN_is_zero(a)) {\n        i = BN_set_word(a, w);\n        if (i != 0)\n            BN_set_negative(a, 1);\n        return i;\n    }\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_add_word(a, w);\n        a->neg = 1;\n        return i;\n    }\n    if ((a->top == 1) && (a->d[0] < w)) {\n        a->d[0] = w - a->d[0];\n        a->neg = 1;\n        return 1;\n    }\n    i = 0;\n    for (;;) {\n        if (a->d[i] >= w) {\n            a->d[i] -= w;\n            break;\n        } else {\n            a->d[i] = (a->d[i] - w) & BN_MASK2;\n            i++;\n            w = 1;\n        }\n    }\n    if ((a->d[i] == 0) && (i == (a->top - 1)))\n        a->top--;\n    bn_check_top(a);\n    return 1;\n}']