crypto/ec/ec2_oct.c:61: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_GF2m_mod_arr`.
Showing all 10 steps of the trace


crypto/ec/ec2_oct.c:54:11: Call
52.   
53.       BN_CTX_start(ctx);
54.       tmp = BN_CTX_get(ctx);
                ^
55.       x = BN_CTX_get(ctx);
56.       y = 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/ec/ec2_oct.c:61:10: Call
59.           goto err;
60.   
61.       if (!BN_GF2m_mod_arr(x, x_, group->poly))
               ^
62.           goto err;
63.       if (BN_is_zero(x)) {

crypto/bn/bn_gf2m.c:290:1: <Length trace>
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: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:316:5: Assignment
  314.           r->top = a->top;
  315.       }
  316.       z = r->d;
             ^
  317.   
  318.       /* start reduction */

crypto/bn/bn_gf2m.c:362:9: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_GF2m_mod_arr` 
  360.           else
  361.               z[dN] = 0;
  362.           z[0] ^= zz;             /* reduction t^0 component */
                 ^
  363.   
  364.           for (k = 1; p[k] != 0; k++) {

int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[])
{
    int j, k;
    int n, dN, d0, d1;
    BN_ULONG zz, *z;
    bn_check_top(a);
    if (!p[0]) {
        BN_zero(r);
        return 1;
    }
    if (a != r) {
        if (!bn_wexpand(r, a->top))
            return 0;
        for (j = 0; j < a->top; j++) {
            r->d[j] = a->d[j];
        }
        r->top = a->top;
    }
    z = r->d;
    dN = p[0] / BN_BITS2;
    for (j = r->top - 1; j > dN;) {
        zz = z[j];
        if (z[j] == 0) {
            j--;
            continue;
        }
        z[j] = 0;
        for (k = 1; p[k] != 0; k++) {
            n = p[0] - p[k];
            d0 = n % BN_BITS2;
            d1 = BN_BITS2 - d0;
            n /= BN_BITS2;
            z[j - n] ^= (zz >> d0);
            if (d0)
                z[j - n - 1] ^= (zz << d1);
        }
        n = dN;
        d0 = p[0] % BN_BITS2;
        d1 = BN_BITS2 - d0;
        z[j - n] ^= (zz >> d0);
        if (d0)
            z[j - n - 1] ^= (zz << d1);
    }
    while (j == dN) {
        d0 = p[0] % BN_BITS2;
        zz = z[dN] >> d0;
        if (zz == 0)
            break;
        d1 = BN_BITS2 - d0;
        if (d0)
            z[dN] = (z[dN] << d1) >> d1;
        else
            z[dN] = 0;
        z[0] ^= zz;
        for (k = 1; p[k] != 0; k++) {
            BN_ULONG tmp_ulong;
            n = p[k] / BN_BITS2;
            d0 = p[k] % BN_BITS2;
            d1 = BN_BITS2 - d0;
            z[n] ^= (zz << d0);
            if (d0 && (tmp_ulong = zz >> d1))
                z[n + 1] ^= tmp_ulong;
        }
    }
    bn_correct_top(r);
    return 1;
}
['int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,\n                                              EC_POINT *point,\n                                              const BIGNUM *x_, int y_bit,\n                                              BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp, *x, *y, *z;\n    int ret = 0, z0;\n    ERR_clear_error();\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n    y_bit = (y_bit != 0) ? 1 : 0;\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    x = BN_CTX_get(ctx);\n    y = BN_CTX_get(ctx);\n    z = BN_CTX_get(ctx);\n    if (z == NULL)\n        goto err;\n    if (!BN_GF2m_mod_arr(x, x_, group->poly))\n        goto err;\n    if (BN_is_zero(x)) {\n        if (!BN_GF2m_mod_sqrt_arr(y, group->b, group->poly, ctx))\n            goto err;\n    } else {\n        if (!group->meth->field_sqr(group, tmp, x, ctx))\n            goto err;\n        if (!group->meth->field_div(group, tmp, group->b, tmp, ctx))\n            goto err;\n        if (!BN_GF2m_add(tmp, group->a, tmp))\n            goto err;\n        if (!BN_GF2m_add(tmp, x, tmp))\n            goto err;\n        if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) {\n            unsigned long err = ERR_peek_last_error();\n            if (ERR_GET_LIB(err) == ERR_LIB_BN\n                && ERR_GET_REASON(err) == BN_R_NO_SOLUTION) {\n                ERR_clear_error();\n                ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES,\n                      EC_R_INVALID_COMPRESSED_POINT);\n            } else\n                ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES,\n                      ERR_R_BN_LIB);\n            goto err;\n        }\n        z0 = (BN_is_odd(z)) ? 1 : 0;\n        if (!group->meth->field_mul(group, y, x, z, ctx))\n            goto err;\n        if (z0 != y_bit) {\n            if (!BN_GF2m_add(y, y, x))\n                goto err;\n        }\n    }\n    if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx))\n        goto err;\n    ret = 1;\n err:\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_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}']