crypto/bn/bn_gf2m.c:1050: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_GF2m_mod_arr`.
Showing all 13 steps of the trace


crypto/bn/bn_gf2m.c:1044:9: Call
1042.   
1043.       BN_CTX_start(ctx);
1044.       a = BN_CTX_get(ctx);
                ^
1045.       z = BN_CTX_get(ctx);
1046.       w = 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:387:1: Parameter `*a->d`
    385.   }
    386.   
    387. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    388.   {
    389.       bn_check_top(a);

crypto/bn/bn_lib.c:390:9: Call
    388.   {
    389.       bn_check_top(a);
    390.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    391.           return 0;
    392.       a->neg = 0;

crypto/bn/bn_lcl.h:651:1: Parameter `*a->d`
      649.                            const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
      650.   
      651. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
      652.   {
      653.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/bn/bn_gf2m.c:1050:10: Call
1048.           goto err;
1049.   
1050.       if (!BN_GF2m_mod_arr(a, a_, p))
                 ^
1051.           goto err;
1052.   

crypto/bn/bn_gf2m.c:290:1: Parameter `*r->d`
  288.   
  289.   /* Performs modular reduction of a and store result in r.  r could be a. */
  290. > int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[])
  291.   {
  292.       int j, k;

crypto/bn/bn_gf2m.c:300:9: Call
  298.       if (!p[0]) {
  299.           /* reduction mod 1 => return 0 */
  300.           BN_zero(r);
                 ^
  301.           return 1;
  302.       }

crypto/bn/bn_lib.c:387:1: <Length trace>
385.   }
386.   
387. > int BN_set_word(BIGNUM *a, BN_ULONG w)
388.   {
389.       bn_check_top(a);

crypto/bn/bn_lib.c:387:1: Parameter `*a->d`
    385.   }
    386.   
    387. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    388.   {
    389.       bn_check_top(a);

crypto/bn/bn_lib.c:390:9: Call
    388.   {
    389.       bn_check_top(a);
    390.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    391.           return 0;
    392.       a->neg = 0;

crypto/bn/bn_lcl.h:651:1: Parameter `*a->d`
      649.                            const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
      650.   
      651. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
      652.   {
      653.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/bn/bn_lib.c:393:5: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_GF2m_mod_arr` 
    391.           return 0;
    392.       a->neg = 0;
    393.       a->d[0] = w;
               ^
    394.       a->top = (w ? 1 : 0);
    395.       bn_check_top(a);

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);
    bn_check_top(a);
    return 1;
}
['int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[],\n                               BN_CTX *ctx)\n{\n    int ret = 0, count = 0, j;\n    BIGNUM *a, *z, *rho, *w, *w2, *tmp;\n    bn_check_top(a_);\n    if (!p[0]) {\n        BN_zero(r);\n        return 1;\n    }\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    z = BN_CTX_get(ctx);\n    w = BN_CTX_get(ctx);\n    if (w == NULL)\n        goto err;\n    if (!BN_GF2m_mod_arr(a, a_, p))\n        goto err;\n    if (BN_is_zero(a)) {\n        BN_zero(r);\n        ret = 1;\n        goto err;\n    }\n    if (p[0] & 0x1) {\n        if (!BN_copy(z, a))\n            goto err;\n        for (j = 1; j <= (p[0] - 1) / 2; j++) {\n            if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx))\n                goto err;\n            if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx))\n                goto err;\n            if (!BN_GF2m_add(z, z, a))\n                goto err;\n        }\n    } else {\n        rho = BN_CTX_get(ctx);\n        w2 = BN_CTX_get(ctx);\n        tmp = BN_CTX_get(ctx);\n        if (tmp == NULL)\n            goto err;\n        do {\n            if (!BN_priv_rand(rho, p[0], BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))\n                goto err;\n            if (!BN_GF2m_mod_arr(rho, rho, p))\n                goto err;\n            BN_zero(z);\n            if (!BN_copy(w, rho))\n                goto err;\n            for (j = 1; j <= p[0] - 1; j++) {\n                if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx))\n                    goto err;\n                if (!BN_GF2m_mod_sqr_arr(w2, w, p, ctx))\n                    goto err;\n                if (!BN_GF2m_mod_mul_arr(tmp, w2, a, p, ctx))\n                    goto err;\n                if (!BN_GF2m_add(z, z, tmp))\n                    goto err;\n                if (!BN_GF2m_add(w, w2, rho))\n                    goto err;\n            }\n            count++;\n        } while (BN_is_zero(w) && (count < MAX_ITERATIONS));\n        if (BN_is_zero(w)) {\n            BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR, BN_R_TOO_MANY_ITERATIONS);\n            goto err;\n        }\n    }\n    if (!BN_GF2m_mod_sqr_arr(w, z, p, ctx))\n        goto err;\n    if (!BN_GF2m_add(w, z, w))\n        goto err;\n    if (BN_GF2m_cmp(w, a)) {\n        BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR, BN_R_NO_SOLUTION);\n        goto err;\n    }\n    if (!BN_copy(r, z))\n        goto err;\n    bn_check_top(r);\n    ret = 1;\n err:\n    BN_CTX_end(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_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[])\n{\n    int j, k;\n    int n, dN, d0, d1;\n    BN_ULONG zz, *z;\n    bn_check_top(a);\n    if (!p[0]) {\n        BN_zero(r);\n        return 1;\n    }\n    if (a != r) {\n        if (!bn_wexpand(r, a->top))\n            return 0;\n        for (j = 0; j < a->top; j++) {\n            r->d[j] = a->d[j];\n        }\n        r->top = a->top;\n    }\n    z = r->d;\n    dN = p[0] / BN_BITS2;\n    for (j = r->top - 1; j > dN;) {\n        zz = z[j];\n        if (z[j] == 0) {\n            j--;\n            continue;\n        }\n        z[j] = 0;\n        for (k = 1; p[k] != 0; k++) {\n            n = p[0] - p[k];\n            d0 = n % BN_BITS2;\n            d1 = BN_BITS2 - d0;\n            n /= BN_BITS2;\n            z[j - n] ^= (zz >> d0);\n            if (d0)\n                z[j - n - 1] ^= (zz << d1);\n        }\n        n = dN;\n        d0 = p[0] % BN_BITS2;\n        d1 = BN_BITS2 - d0;\n        z[j - n] ^= (zz >> d0);\n        if (d0)\n            z[j - n - 1] ^= (zz << d1);\n    }\n    while (j == dN) {\n        d0 = p[0] % BN_BITS2;\n        zz = z[dN] >> d0;\n        if (zz == 0)\n            break;\n        d1 = BN_BITS2 - d0;\n        if (d0)\n            z[dN] = (z[dN] << d1) >> d1;\n        else\n            z[dN] = 0;\n        z[0] ^= zz;\n        for (k = 1; p[k] != 0; k++) {\n            BN_ULONG tmp_ulong;\n            n = p[k] / BN_BITS2;\n            d0 = p[k] % BN_BITS2;\n            d1 = BN_BITS2 - d0;\n            z[n] ^= (zz << d0);\n            if (d0 && (tmp_ulong = zz >> d1))\n                z[n + 1] ^= tmp_ulong;\n        }\n    }\n    bn_correct_top(r);\n    return 1;\n}']