crypto/ec/ecp_smpl.c:291: error: BUFFER_OVERRUN_L3
  Offset added: [0, 16] Size: [0, 536870848] by call to `BN_lshift`.
Showing all 15 steps of the trace


crypto/ec/ecp_smpl.c:258:9: Call
256.       }
257.       BN_CTX_start(ctx);
258.       a = BN_CTX_get(ctx);
               ^
259.       b = BN_CTX_get(ctx);
260.       tmp_1 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:229:5: Call
  227.       }
  228.       /* OK, make sure the returned bignum is "zero" */
  229.       BN_zero(ret);
             ^
  230.       ctx->used++;
  231.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:463:1: Parameter `*a->d`
    461.   }
    462.   
    463. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    464.   {
    465.       bn_check_top(a);

crypto/bn/bn_lib.c:466:9: Call
    464.   {
    465.       bn_check_top(a);
    466.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    467.           return (0);
    468.       a->neg = 0;

crypto/bn/bn_lcl.h:674:1: Parameter `*a->d`
      672.   int bn_probable_prime_dh_coprime(BIGNUM *rnd, int bits, BN_CTX *ctx);
      673.   
      674. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
      675.   {
      676.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/ec/ecp_smpl.c:291:14: Call
289.           if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx))
290.               goto err;
291.           if (!BN_lshift(tmp_1, tmp_2, 2))
                    ^
292.               goto err;
293.           /* tmp_1 = 4*a^3 */

crypto/bn/bn_shift.c:81:1: <Offset trace>
79.   }
80.   
81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
82.   {
83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:81:1: Parameter `n`
  79.   }
  80.   
  81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
  82.   {
  83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:95:5: Assignment
  93.       }
  94.   
  95.       nw = n / BN_BITS2;
            ^
  96.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
  97.           return (0);

crypto/bn/bn_shift.c:81:1: <Length trace>
79.   }
80.   
81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
82.   {
83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:81:1: Parameter `*r->d`
  79.   }
  80.   
  81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
  82.   {
  83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:96:9: Call
  94.   
  95.       nw = n / BN_BITS2;
  96.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
                ^
  97.           return (0);
  98.       r->neg = a->neg;

crypto/bn/bn_lib.c:1016:1: Parameter `*a->d`
    1014.   }
    1015.   
    1016. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1017.   {
    1018.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_shift.c:102:5: Assignment
  100.       rb = BN_BITS2 - lb;
  101.       f = a->d;
  102.       t = r->d;
             ^
  103.       t[a->top + nw] = 0;
  104.       if (lb == 0)

crypto/bn/bn_shift.c:113:5: Array access: Offset added: [0, 16] Size: [0, 536870848] by call to `BN_lshift` 
  111.               t[nw + i] = (l << lb) & BN_MASK2;
  112.           }
  113.       memset(t, 0, sizeof(*t) * nw);
             ^
  114.       r->top = a->top + nw + 1;
  115.       bn_correct_top(r);

int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
{
    int i, nw, lb, rb;
    BN_ULONG *t, *f;
    BN_ULONG l;
    bn_check_top(r);
    bn_check_top(a);
    if (n < 0) {
        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);
        return 0;
    }
    nw = n / BN_BITS2;
    if (bn_wexpand(r, a->top + nw + 1) == NULL)
        return (0);
    r->neg = a->neg;
    lb = n % BN_BITS2;
    rb = BN_BITS2 - lb;
    f = a->d;
    t = r->d;
    t[a->top + nw] = 0;
    if (lb == 0)
        for (i = a->top - 1; i >= 0; i--)
            t[nw + i] = f[i];
    else
        for (i = a->top - 1; i >= 0; i--) {
            l = f[i];
            t[nw + i + 1] |= (l >> rb) & BN_MASK2;
            t[nw + i] = (l << lb) & BN_MASK2;
        }
    memset(t, 0, sizeof(*t) * nw);
    r->top = a->top + nw + 1;
    bn_correct_top(r);
    bn_check_top(r);
    return (1);
}
['int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *a, *b, *order, *tmp_1, *tmp_2;\n    const BIGNUM *p = group->field;\n    BN_CTX *new_ctx = NULL;\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL) {\n            ECerr(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT,\n                  ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    tmp_1 = BN_CTX_get(ctx);\n    tmp_2 = BN_CTX_get(ctx);\n    order = BN_CTX_get(ctx);\n    if (order == NULL)\n        goto err;\n    if (group->meth->field_decode) {\n        if (!group->meth->field_decode(group, a, group->a, ctx))\n            goto err;\n        if (!group->meth->field_decode(group, b, group->b, ctx))\n            goto err;\n    } else {\n        if (!BN_copy(a, group->a))\n            goto err;\n        if (!BN_copy(b, group->b))\n            goto err;\n    }\n    if (BN_is_zero(a)) {\n        if (BN_is_zero(b))\n            goto err;\n    } else if (!BN_is_zero(b)) {\n        if (!BN_mod_sqr(tmp_1, a, p, ctx))\n            goto err;\n        if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx))\n            goto err;\n        if (!BN_lshift(tmp_1, tmp_2, 2))\n            goto err;\n        if (!BN_mod_sqr(tmp_2, b, p, ctx))\n            goto err;\n        if (!BN_mul_word(tmp_2, 27))\n            goto err;\n        if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx))\n            goto err;\n        if (BN_is_zero(a))\n            goto err;\n    }\n    ret = 1;\n err:\n    if (ctx != NULL)\n        BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG_ENTRY("BN_CTX_get", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    BN_zero(ret);\n    ctx->used++;\n    CTXDBG_RET(ctx, ret);\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    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}', 'int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, nw, lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l;\n    bn_check_top(r);\n    bn_check_top(a);\n    if (n < 0) {\n        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n    nw = n / BN_BITS2;\n    if (bn_wexpand(r, a->top + nw + 1) == NULL)\n        return (0);\n    r->neg = a->neg;\n    lb = n % BN_BITS2;\n    rb = BN_BITS2 - lb;\n    f = a->d;\n    t = r->d;\n    t[a->top + nw] = 0;\n    if (lb == 0)\n        for (i = a->top - 1; i >= 0; i--)\n            t[nw + i] = f[i];\n    else\n        for (i = a->top - 1; i >= 0; i--) {\n            l = f[i];\n            t[nw + i + 1] |= (l >> rb) & BN_MASK2;\n            t[nw + i] = (l << lb) & BN_MASK2;\n        }\n    memset(t, 0, sizeof(*t) * nw);\n    r->top = a->top + nw + 1;\n    bn_correct_top(r);\n    bn_check_top(r);\n    return (1);\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']