crypto/dsa/dsa_ossl.c:346: error: BUFFER_OVERRUN_L3
  Offset: [31, +oo] Size: [0, 8388607] by call to `BN_mod_mul`.
Showing all 17 steps of the trace


crypto/dsa/dsa_ossl.c:342:10: Call
340.   
341.       /* u1 = M * w mod q */
342.       if (!BN_mod_mul(u1, u1, u2, dsa->q, ctx))
                ^
343.           goto err;
344.   

crypto/bn/bn_mod.c:193:1: Parameter `r->top`
  191.   
  192.   /* slow but works */
  193. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  194.                  BN_CTX *ctx)
  195.   {

crypto/dsa/dsa_ossl.c:346:10: Call
344.   
345.       /* u2 = r * w mod q */
346.       if (!BN_mod_mul(u2, r, u2, dsa->q, ctx))
                ^
347.           goto err;
348.   

crypto/bn/bn_mod.c:193:1: Parameter `a->top`
  191.   
  192.   /* slow but works */
  193. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  194.                  BN_CTX *ctx)
  195.   {

crypto/bn/bn_mod.c:207:14: Call
  205.           goto err;
  206.       if (a == b) {
  207.           if (!BN_sqr(t, a, ctx))
                      ^
  208.               goto err;
  209.       } else {

crypto/bn/bn_sqr.c:17:1: Parameter `*r->d`
    15.    * I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96
    16.    */
    17. > int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    18.   {
    19.       int ret = bn_sqr_fixed_top(r, a, ctx);

crypto/bn/bn_sqr.c:19:15: Call
    17.   int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    18.   {
    19.       int ret = bn_sqr_fixed_top(r, a, ctx);
                        ^
    20.   
    21.       bn_correct_top(r);

crypto/bn/bn_sqr.c:27:1: Parameter `a->top`
      25.   }
      26.   
      27. > int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
      28.   {
      29.       int max, al;

crypto/bn/bn_sqr.c:35:5: Assignment
      33.       bn_check_top(a);
      34.   
      35.       al = a->top;
                ^
      36.       if (al <= 0) {
      37.           r->top = 0;

crypto/bn/bn_sqr.c:84:17: Call
      82.                   if (bn_wexpand(tmp, max) == NULL)
      83.                       goto err;
      84.                   bn_sqr_normal(rr->d, a->d, al, tmp->d);
                            ^
      85.               }
      86.           }

crypto/bn/bn_sqr.c:109:1: <Offset trace>
107.   
108.   /* tmp must have 2*n words */
109. > void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
110.   {
111.       int i, j, max;

crypto/bn/bn_sqr.c:109:1: Parameter `n`
        107.   
        108.   /* tmp must have 2*n words */
        109. > void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
        110.   {
        111.       int i, j, max;

crypto/bn/bn_sqr.c:115:5: Assignment
        113.       BN_ULONG *rp;
        114.   
        115.       max = n * 2;
                   ^
        116.       ap = a;
        117.       rp = r;

crypto/bn/bn_sqr.c:109:1: <Length trace>
107.   
108.   /* tmp must have 2*n words */
109. > void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
110.   {
111.       int i, j, max;

crypto/bn/bn_sqr.c:109:1: Parameter `*r`
        107.   
        108.   /* tmp must have 2*n words */
        109. > void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
        110.   {
        111.       int i, j, max;

crypto/bn/bn_sqr.c:117:5: Assignment
        115.       max = n * 2;
        116.       ap = a;
        117.       rp = r;
                   ^
        118.       rp[0] = rp[max - 1] = 0;
        119.       rp++;

crypto/bn/bn_sqr.c:118:13: Array access: Offset: [31, +oo] Size: [0, 8388607] by call to `BN_mod_mul` 
        116.       ap = a;
        117.       rp = r;
        118.       rp[0] = rp[max - 1] = 0;
                           ^
        119.       rp++;
        120.       j = n;

void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
{
    int i, j, max;
    const BN_ULONG *ap;
    BN_ULONG *rp;
    max = n * 2;
    ap = a;
    rp = r;
    rp[0] = rp[max - 1] = 0;
    rp++;
    j = n;
    if (--j > 0) {
        ap++;
        rp[j] = bn_mul_words(rp, ap, j, ap[-1]);
        rp += 2;
    }
    for (i = n - 2; i > 0; i--) {
        j--;
        ap++;
        rp[j] = bn_mul_add_words(rp, ap, j, ap[-1]);
        rp += 2;
    }
    bn_add_words(r, r, r, max);
    bn_sqr_words(tmp, a, n);
    bn_add_words(r, r, tmp, max);
}
['static int dsa_do_verify(const unsigned char *dgst, int dgst_len,\n                         DSA_SIG *sig, DSA *dsa)\n{\n    BN_CTX *ctx;\n    BIGNUM *u1, *u2, *t1;\n    BN_MONT_CTX *mont = NULL;\n    const BIGNUM *r, *s;\n    int ret = -1, i;\n    if (!dsa->p || !dsa->q || !dsa->g) {\n        DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_MISSING_PARAMETERS);\n        return -1;\n    }\n    i = BN_num_bits(dsa->q);\n    if (i != 160 && i != 224 && i != 256) {\n        DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_BAD_Q_VALUE);\n        return -1;\n    }\n    if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) {\n        DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_MODULUS_TOO_LARGE);\n        return -1;\n    }\n    u1 = BN_new();\n    u2 = BN_new();\n    t1 = BN_new();\n    ctx = BN_CTX_new();\n    if (u1 == NULL || u2 == NULL || t1 == NULL || ctx == NULL)\n        goto err;\n    DSA_SIG_get0(sig, &r, &s);\n    if (BN_is_zero(r) || BN_is_negative(r) ||\n        BN_ucmp(r, dsa->q) >= 0) {\n        ret = 0;\n        goto err;\n    }\n    if (BN_is_zero(s) || BN_is_negative(s) ||\n        BN_ucmp(s, dsa->q) >= 0) {\n        ret = 0;\n        goto err;\n    }\n    if ((BN_mod_inverse(u2, s, dsa->q, ctx)) == NULL)\n        goto err;\n    if (dgst_len > (i >> 3))\n        dgst_len = (i >> 3);\n    if (BN_bin2bn(dgst, dgst_len, u1) == NULL)\n        goto err;\n    if (!BN_mod_mul(u1, u1, u2, dsa->q, ctx))\n        goto err;\n    if (!BN_mod_mul(u2, r, u2, dsa->q, ctx))\n        goto err;\n    if (dsa->flags & DSA_FLAG_CACHE_MONT_P) {\n        mont = BN_MONT_CTX_set_locked(&dsa->method_mont_p,\n                                      dsa->lock, dsa->p, ctx);\n        if (!mont)\n            goto err;\n    }\n    if (dsa->meth->dsa_mod_exp != NULL) {\n        if (!dsa->meth->dsa_mod_exp(dsa, t1, dsa->g, u1, dsa->pub_key, u2,\n                                    dsa->p, ctx, mont))\n            goto err;\n    } else {\n        if (!BN_mod_exp2_mont(t1, dsa->g, u1, dsa->pub_key, u2, dsa->p, ctx,\n                              mont))\n            goto err;\n    }\n    if (!BN_mod(u1, t1, dsa->q, ctx))\n        goto err;\n    ret = (BN_ucmp(u1, r) == 0);\n err:\n    if (ret < 0)\n        DSAerr(DSA_F_DSA_DO_VERIFY, ERR_R_BN_LIB);\n    BN_CTX_free(ctx);\n    BN_free(u1);\n    BN_free(u2);\n    BN_free(t1);\n    return ret;\n}', 'int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int ret = 0;\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(m);\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (a == b) {\n        if (!BN_sqr(t, a, ctx))\n            goto err;\n    } else {\n        if (!BN_mul(t, a, b, ctx))\n            goto err;\n    }\n    if (!BN_nnmod(r, t, m, ctx))\n        goto err;\n    bn_check_top(r);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int ret = bn_sqr_fixed_top(r, a, ctx);\n    bn_correct_top(r);\n    bn_check_top(r);\n    return ret;\n}', 'int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int max, al;\n    int ret = 0;\n    BIGNUM *tmp, *rr;\n    bn_check_top(a);\n    al = a->top;\n    if (al <= 0) {\n        r->top = 0;\n        r->neg = 0;\n        return 1;\n    }\n    BN_CTX_start(ctx);\n    rr = (a != r) ? r : BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (rr == NULL || tmp == NULL)\n        goto err;\n    max = 2 * al;\n    if (bn_wexpand(rr, max) == NULL)\n        goto err;\n    if (al == 4) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[8];\n        bn_sqr_normal(rr->d, a->d, 4, t);\n#else\n        bn_sqr_comba4(rr->d, a->d);\n#endif\n    } else if (al == 8) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[16];\n        bn_sqr_normal(rr->d, a->d, 8, t);\n#else\n        bn_sqr_comba8(rr->d, a->d);\n#endif\n    } else {\n#if defined(BN_RECURSION)\n        if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) {\n            BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL * 2];\n            bn_sqr_normal(rr->d, a->d, al, t);\n        } else {\n            int j, k;\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            if (al == j) {\n                if (bn_wexpand(tmp, k * 2) == NULL)\n                    goto err;\n                bn_sqr_recursive(rr->d, a->d, al, tmp->d);\n            } else {\n                if (bn_wexpand(tmp, max) == NULL)\n                    goto err;\n                bn_sqr_normal(rr->d, a->d, al, tmp->d);\n            }\n        }\n#else\n        if (bn_wexpand(tmp, max) == NULL)\n            goto err;\n        bn_sqr_normal(rr->d, a->d, al, tmp->d);\n#endif\n    }\n    rr->neg = 0;\n    rr->top = max;\n    rr->flags |= BN_FLG_FIXED_TOP;\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n    ret = 1;\n err:\n    bn_check_top(rr);\n    bn_check_top(tmp);\n    BN_CTX_end(ctx);\n    return ret;\n}', 'void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)\n{\n    int i, j, max;\n    const BN_ULONG *ap;\n    BN_ULONG *rp;\n    max = n * 2;\n    ap = a;\n    rp = r;\n    rp[0] = rp[max - 1] = 0;\n    rp++;\n    j = n;\n    if (--j > 0) {\n        ap++;\n        rp[j] = bn_mul_words(rp, ap, j, ap[-1]);\n        rp += 2;\n    }\n    for (i = n - 2; i > 0; i--) {\n        j--;\n        ap++;\n        rp[j] = bn_mul_add_words(rp, ap, j, ap[-1]);\n        rp += 2;\n    }\n    bn_add_words(r, r, r, max);\n    bn_sqr_words(tmp, a, n);\n    bn_add_words(r, r, tmp, max);\n}']