crypto/ec/ec_lib.c:304: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 67108856] by call to `ec_precompute_mont_data`.
Showing all 18 steps of the trace


crypto/ec/ec_lib.c:285:14: Call
283.   
284.       if (order != NULL) {
285.           if (!BN_copy(group->order, order))
                    ^
286.               return 0;
287.       } else {

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

crypto/ec/ec_lib.c:303:9: Call
301.        * |group->mont_data| will be NULL in this case.
302.        */
303.       if (BN_is_odd(group->order)) {
               ^
304.           return ec_precompute_mont_data(group);
305.       }

crypto/bn/bn_lib.c:881:1: Parameter `a->top`
  879.   }
  880.   
  881. > int BN_is_odd(const BIGNUM *a)
  882.   {
  883.       return (a->top > 0) && (a->d[0] & 1);

crypto/ec/ec_lib.c:304:16: Call
302.        */
303.       if (BN_is_odd(group->order)) {
304.           return ec_precompute_mont_data(group);
                      ^
305.       }
306.   

crypto/ec/ec_lib.c:1015:1: Parameter `group->order->top`
  1013.    * returns one on success. On error it returns zero.
  1014.    */
  1015. > static int ec_precompute_mont_data(EC_GROUP *group)
  1016.   {
  1017.       BN_CTX *ctx = BN_CTX_new();

crypto/ec/ec_lib.c:1030:10: Call
  1028.           goto err;
  1029.   
  1030.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
                   ^
  1031.           BN_MONT_CTX_free(group->mont_data);
  1032.           group->mont_data = NULL;

crypto/bn/bn_mont.c:263:1: Parameter `mod->top`
    261.   }
    262.   
    263. > int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
    264.   {
    265.       int i, ret = 0;

crypto/bn/bn_mont.c:268:9: Call
    266.       BIGNUM *Ri, *R;
    267.   
    268.       if (BN_is_zero(mod))
                   ^
    269.           return 0;
    270.   

crypto/bn/bn_lib.c:866:1: Parameter `a->top`
      864.   }
      865.   
      866. > int BN_is_zero(const BIGNUM *a)
      867.   {
      868.       return a->top == 0;

crypto/bn/bn_mont.c:275:10: Call
    273.           goto err;
    274.       R = &(mont->RR);            /* grab RR as a temp */
    275.       if (!BN_copy(&(mont->N), mod))
                    ^
    276.           goto err;               /* Set N */
    277.       if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)

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 `*a->d`
      279.   }
      280.   
      281. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
      282.   {
      283.       bn_check_top(b);

crypto/bn/bn_lib.c:287:9: Call
      285.       if (a == b)
      286.           return a;
      287.       if (bn_wexpand(a, b->top) == NULL)
                     ^
      288.           return NULL;
      289.   

crypto/bn/bn_lib.c:962:1: Parameter `*a->d`
        960.   }
        961.   
        962. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
        963.   {
        964.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:291:9: Array access: Offset added: [8, +oo] Size: [0, 67108856] by call to `ec_precompute_mont_data` 
      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;
}
['int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor)\n{\n    if (generator == NULL) {\n        ECerr(EC_F_EC_GROUP_SET_GENERATOR, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    if (group->generator == NULL) {\n        group->generator = EC_POINT_new(group);\n        if (group->generator == NULL)\n            return 0;\n    }\n    if (!EC_POINT_copy(group->generator, generator))\n        return 0;\n    if (order != NULL) {\n        if (!BN_copy(group->order, order))\n            return 0;\n    } else {\n        BN_zero(group->order);\n    }\n    if (cofactor != NULL) {\n        if (!BN_copy(group->cofactor, cofactor))\n            return 0;\n    } else {\n        BN_zero(group->cofactor);\n    }\n    if (BN_is_odd(group->order)) {\n        return ec_precompute_mont_data(group);\n    }\n    BN_MONT_CTX_free(group->mont_data);\n    group->mont_data = NULL;\n    return 1;\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}', 'int BN_is_odd(const BIGNUM *a)\n{\n    return (a->top > 0) && (a->d[0] & 1);\n}', 'static int ec_precompute_mont_data(EC_GROUP *group)\n{\n    BN_CTX *ctx = BN_CTX_new();\n    int ret = 0;\n    BN_MONT_CTX_free(group->mont_data);\n    group->mont_data = NULL;\n    if (ctx == NULL)\n        goto err;\n    group->mont_data = BN_MONT_CTX_new();\n    if (group->mont_data == NULL)\n        goto err;\n    if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {\n        BN_MONT_CTX_free(group->mont_data);\n        group->mont_data = NULL;\n        goto err;\n    }\n    ret = 1;\n err:\n    BN_CTX_free(ctx);\n    return ret;\n}', 'int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)\n{\n    int i, ret = 0;\n    BIGNUM *Ri, *R;\n    if (BN_is_zero(mod))\n        return 0;\n    BN_CTX_start(ctx);\n    if ((Ri = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    R = &(mont->RR);\n    if (!BN_copy(&(mont->N), mod))\n        goto err;\n    if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)\n        BN_set_flags(&(mont->N), BN_FLG_CONSTTIME);\n    mont->N.neg = 0;\n#ifdef MONT_WORD\n    {\n        BIGNUM tmod;\n        BN_ULONG buf[2];\n        bn_init(&tmod);\n        tmod.d = buf;\n        tmod.dmax = 2;\n        tmod.neg = 0;\n        if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)\n            BN_set_flags(&tmod, BN_FLG_CONSTTIME);\n        mont->ri = (BN_num_bits(mod) + (BN_BITS2 - 1)) / BN_BITS2 * BN_BITS2;\n# if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32)\n        BN_zero(R);\n        if (!(BN_set_bit(R, 2 * BN_BITS2)))\n            goto err;\n        tmod.top = 0;\n        if ((buf[0] = mod->d[0]))\n            tmod.top = 1;\n        if ((buf[1] = mod->top > 1 ? mod->d[1] : 0))\n            tmod.top = 2;\n        if (BN_is_one(&tmod))\n            BN_zero(Ri);\n        else if ((BN_mod_inverse(Ri, R, &tmod, ctx)) == NULL)\n            goto err;\n        if (!BN_lshift(Ri, Ri, 2 * BN_BITS2))\n            goto err;\n        if (!BN_is_zero(Ri)) {\n            if (!BN_sub_word(Ri, 1))\n                goto err;\n        } else {\n            if (bn_expand(Ri, (int)sizeof(BN_ULONG) * 2) == NULL)\n                goto err;\n            Ri->neg = 0;\n            Ri->d[0] = BN_MASK2;\n            Ri->d[1] = BN_MASK2;\n            Ri->top = 2;\n        }\n        if (!BN_div(Ri, NULL, Ri, &tmod, ctx))\n            goto err;\n        mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0;\n        mont->n0[1] = (Ri->top > 1) ? Ri->d[1] : 0;\n# else\n        BN_zero(R);\n        if (!(BN_set_bit(R, BN_BITS2)))\n            goto err;\n        buf[0] = mod->d[0];\n        buf[1] = 0;\n        tmod.top = buf[0] != 0 ? 1 : 0;\n        if (BN_is_one(&tmod))\n            BN_zero(Ri);\n        else if ((BN_mod_inverse(Ri, R, &tmod, ctx)) == NULL)\n            goto err;\n        if (!BN_lshift(Ri, Ri, BN_BITS2))\n            goto err;\n        if (!BN_is_zero(Ri)) {\n            if (!BN_sub_word(Ri, 1))\n                goto err;\n        } else {\n            if (!BN_set_word(Ri, BN_MASK2))\n                goto err;\n        }\n        if (!BN_div(Ri, NULL, Ri, &tmod, ctx))\n            goto err;\n        mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0;\n        mont->n0[1] = 0;\n# endif\n    }\n#else\n    {\n        mont->ri = BN_num_bits(&mont->N);\n        BN_zero(R);\n        if (!BN_set_bit(R, mont->ri))\n            goto err;\n        if ((BN_mod_inverse(Ri, R, &mont->N, ctx)) == NULL)\n            goto err;\n        if (!BN_lshift(Ri, Ri, mont->ri))\n            goto err;\n        if (!BN_sub_word(Ri, 1))\n            goto err;\n        if (!BN_div(&(mont->Ni), NULL, Ri, &mont->N, ctx))\n            goto err;\n    }\n#endif\n    BN_zero(&(mont->RR));\n    if (!BN_set_bit(&(mont->RR), mont->ri * 2))\n        goto err;\n    if (!BN_mod(&(mont->RR), &(mont->RR), &(mont->N), ctx))\n        goto err;\n    for (i = mont->RR.top, ret = mont->N.top; i < ret; i++)\n        mont->RR.d[i] = 0;\n    mont->RR.top = ret;\n    mont->RR.flags |= BN_FLG_FIXED_TOP;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}', 'int BN_is_zero(const BIGNUM *a)\n{\n    return a->top == 0;\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']