crypto/bn/bn_gf2m.c:1174: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, 8388607] by call to `BN_GF2m_mod_mul_arr`.
Showing all 8 steps of the trace


crypto/bn/bn_gf2m.c:1132:10: Call
1130.           goto err;
1131.   
1132.       if (!BN_GF2m_mod_arr(a, a_, p))
                 ^
1133.           goto err;
1134.   

crypto/bn/bn_gf2m.c:370:1: Parameter `r->top`
  368.   
  369.   /* Performs modular reduction of a and store result in r.  r could be a. */
  370. > int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[])
  371.   {
  372.       int j, k;

crypto/bn/bn_gf2m.c:1174:22: Call
1172.                   if (!BN_GF2m_mod_sqr_arr(w2, w, p, ctx))
1173.                       goto err;
1174.                   if (!BN_GF2m_mod_mul_arr(tmp, w2, a, p, ctx))
                             ^
1175.                       goto err;
1176.                   if (!BN_GF2m_add(z, z, tmp))

crypto/bn/bn_gf2m.c:488:1: <Offset trace>
486.    * the result in r.  r could be a or b; a could be b.
487.    */
488. > int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
489.                           const int p[], BN_CTX *ctx)
490.   {

crypto/bn/bn_gf2m.c:488:1: Parameter `b->top`
  486.    * the result in r.  r could be a or b; a could be b.
  487.    */
  488. > int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
  489.                           const int p[], BN_CTX *ctx)
  490.   {

crypto/bn/bn_gf2m.c:488:1: <Length trace>
486.    * the result in r.  r could be a or b; a could be b.
487.    */
488. > int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
489.                           const int p[], BN_CTX *ctx)
490.   {

crypto/bn/bn_gf2m.c:488:1: Parameter `*b->d`
  486.    * the result in r.  r could be a or b; a could be b.
  487.    */
  488. > int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
  489.                           const int p[], BN_CTX *ctx)
  490.   {

crypto/bn/bn_gf2m.c:516:40: Array access: Offset: [1, +oo] Size: [0, 8388607] by call to `BN_GF2m_mod_mul_arr` 
  514.       for (j = 0; j < b->top; j += 2) {
  515.           y0 = b->d[j];
  516.           y1 = ((j + 1) == b->top) ? 0 : b->d[j + 1];
                                                ^
  517.           for (i = 0; i < a->top; i += 2) {
  518.               x0 = a->d[i];

int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
                        const int p[], BN_CTX *ctx)
{
    int zlen, i, j, k, ret = 0;
    BIGNUM *s;
    BN_ULONG x1, x0, y1, y0, zz[4];
    bn_check_top(a);
    bn_check_top(b);
    if (a == b) {
        return BN_GF2m_mod_sqr_arr(r, a, p, ctx);
    }
    BN_CTX_start(ctx);
    if ((s = BN_CTX_get(ctx)) == NULL)
        goto err;
    zlen = a->top + b->top + 4;
    if (!bn_wexpand(s, zlen))
        goto err;
    s->top = zlen;
    for (i = 0; i < zlen; i++)
        s->d[i] = 0;
    for (j = 0; j < b->top; j += 2) {
        y0 = b->d[j];
        y1 = ((j + 1) == b->top) ? 0 : b->d[j + 1];
        for (i = 0; i < a->top; i += 2) {
            x0 = a->d[i];
            x1 = ((i + 1) == a->top) ? 0 : a->d[i + 1];
            bn_GF2m_mul_2x2(zz, x1, x0, y1, y0);
            for (k = 0; k < 4; k++)
                s->d[i + j + k] ^= zz[k];
        }
    }
    bn_correct_top(s);
    if (BN_GF2m_mod_arr(r, s, p))
        ret = 1;
    bn_check_top(r);
 err:
    BN_CTX_end(ctx);
    return ret;
}
['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_rand(rho, p[0], 0, 0))\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}', '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}', 'int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx)\n{\n    int zlen, i, j, k, ret = 0;\n    BIGNUM *s;\n    BN_ULONG x1, x0, y1, y0, zz[4];\n    bn_check_top(a);\n    bn_check_top(b);\n    if (a == b) {\n        return BN_GF2m_mod_sqr_arr(r, a, p, ctx);\n    }\n    BN_CTX_start(ctx);\n    if ((s = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    zlen = a->top + b->top + 4;\n    if (!bn_wexpand(s, zlen))\n        goto err;\n    s->top = zlen;\n    for (i = 0; i < zlen; i++)\n        s->d[i] = 0;\n    for (j = 0; j < b->top; j += 2) {\n        y0 = b->d[j];\n        y1 = ((j + 1) == b->top) ? 0 : b->d[j + 1];\n        for (i = 0; i < a->top; i += 2) {\n            x0 = a->d[i];\n            x1 = ((i + 1) == a->top) ? 0 : a->d[i + 1];\n            bn_GF2m_mul_2x2(zz, x1, x0, y1, y0);\n            for (k = 0; k < 4; k++)\n                s->d[i + j + k] ^= zz[k];\n        }\n    }\n    bn_correct_top(s);\n    if (BN_GF2m_mod_arr(r, s, p))\n        ret = 1;\n    bn_check_top(r);\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}']