crypto/dsa/dsa_ossl.c:126: error: BUFFER_OVERRUN_L3
  Offset: [16, +oo] (⇐ 1 + [15, +oo]) Size: [0, 8388607] by call to `BN_mod_mul`.
Showing all 17 steps of the trace


crypto/dsa/dsa_ossl.c:102:9: Call
100.            */
101.           dlen = BN_num_bytes(dsa->q);
102.       if (BN_bin2bn(dgst, dlen, m) == NULL)
               ^
103.           goto err;
104.   

crypto/bn/bn_lib.c:372:1: Parameter `ret->top`
  370.   }
  371.   
  372. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  373.   {
  374.       unsigned int i, m;

crypto/dsa/dsa_ossl.c:126:10: Call
124.   
125.       /* tmp := blind * priv_key * r mod q */
126.       if (!BN_mod_mul(tmp, blind, dsa->priv_key, dsa->q, ctx))
                ^
127.           goto err;
128.       if (!BN_mod_mul(tmp, tmp, ret->r, dsa->q, ctx))

crypto/bn/bn_mod.c:73:1: Parameter `a->top`
  71.   
  72.   /* slow but works */
  73. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  74.                  BN_CTX *ctx)
  75.   {

crypto/bn/bn_mod.c:87:14: Call
  85.           goto err;
  86.       if (a == b) {
  87.           if (!BN_sqr(t, a, ctx))
                     ^
  88.               goto err;
  89.       } else {

crypto/bn/bn_sqr.c:17:1: Parameter `a->top`
    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 max, al;

crypto/bn/bn_sqr.c:25:5: Assignment
    23.       bn_check_top(a);
    24.   
    25.       al = a->top;
              ^
    26.       if (al <= 0) {
    27.           r->top = 0;

crypto/bn/bn_sqr.c:74:17: Call
    72.                   if (bn_wexpand(tmp, max) == NULL)
    73.                       goto err;
    74.                   bn_sqr_normal(rr->d, a->d, al, tmp->d);
                          ^
    75.               }
    76.           }

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

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

crypto/bn/bn_sqr.c:116:5: Assignment
      114.       rp[0] = rp[max - 1] = 0;
      115.       rp++;
      116.       j = n;
                 ^
      117.   
      118.       if (--j > 0) {

crypto/bn/bn_sqr.c:118:9: Assignment
      116.       j = n;
      117.   
      118.       if (--j > 0) {
                     ^
      119.           ap++;
      120.           rp[j] = bn_mul_words(rp, ap, j, ap[-1]);

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

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

crypto/bn/bn_sqr.c:113:5: Assignment
      111.       max = n * 2;
      112.       ap = a;
      113.       rp = r;
                 ^
      114.       rp[0] = rp[max - 1] = 0;
      115.       rp++;

crypto/bn/bn_sqr.c:115:5: Assignment
      113.       rp = r;
      114.       rp[0] = rp[max - 1] = 0;
      115.       rp++;
                 ^
      116.       j = n;
      117.   

crypto/bn/bn_sqr.c:120:9: Array access: Offset: [16, +oo] (⇐ 1 + [15, +oo]) Size: [0, 8388607] by call to `BN_mod_mul` 
      118.       if (--j > 0) {
      119.           ap++;
      120.           rp[j] = bn_mul_words(rp, ap, j, ap[-1]);
                     ^
      121.           rp += 2;
      122.       }

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 DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)\n{\n    BIGNUM *kinv = NULL;\n    BIGNUM *m, *blind, *blindm, *tmp;\n    BN_CTX *ctx = NULL;\n    int reason = ERR_R_BN_LIB;\n    DSA_SIG *ret = NULL;\n    int rv = 0;\n    if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) {\n        reason = DSA_R_MISSING_PARAMETERS;\n        goto err;\n    }\n    ret = DSA_SIG_new();\n    if (ret == NULL)\n        goto err;\n    ret->r = BN_new();\n    ret->s = BN_new();\n    if (ret->r == NULL || ret->s == NULL)\n        goto err;\n    ctx = BN_CTX_new();\n    if (ctx == NULL)\n        goto err;\n    m = BN_CTX_get(ctx);\n    blind = BN_CTX_get(ctx);\n    blindm = BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (tmp == NULL)\n        goto err;\n redo:\n    if (!dsa_sign_setup(dsa, ctx, &kinv, &ret->r, dgst, dlen))\n        goto err;\n    if (dlen > BN_num_bytes(dsa->q))\n        dlen = BN_num_bytes(dsa->q);\n    if (BN_bin2bn(dgst, dlen, m) == NULL)\n        goto err;\n    do {\n        if (!BN_priv_rand(blind, BN_num_bits(dsa->q) - 1,\n                          BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))\n            goto err;\n    } while (BN_is_zero(blind));\n    BN_set_flags(blind, BN_FLG_CONSTTIME);\n    BN_set_flags(blindm, BN_FLG_CONSTTIME);\n    BN_set_flags(tmp, BN_FLG_CONSTTIME);\n    if (!BN_mod_mul(tmp, blind, dsa->priv_key, dsa->q, ctx))\n        goto err;\n    if (!BN_mod_mul(tmp, tmp, ret->r, dsa->q, ctx))\n        goto err;\n    if (!BN_mod_mul(blindm, blind, m, dsa->q, ctx))\n        goto err;\n    if (!BN_mod_add_quick(ret->s, tmp, blindm, dsa->q))\n        goto err;\n    if (!BN_mod_mul(ret->s, ret->s, kinv, dsa->q, ctx))\n        goto err;\n    if (BN_mod_inverse(blind, blind, dsa->q, ctx) == NULL)\n        goto err;\n    if (!BN_mod_mul(ret->s, ret->s, blind, dsa->q, ctx))\n        goto err;\n    if (BN_is_zero(ret->r) || BN_is_zero(ret->s))\n        goto redo;\n    rv = 1;\n err:\n    if (rv == 0) {\n        DSAerr(DSA_F_DSA_DO_SIGN, reason);\n        DSA_SIG_free(ret);\n        ret = NULL;\n    }\n    BN_CTX_free(ctx);\n    BN_clear_free(kinv);\n    return ret;\n}', 'BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n    unsigned int i, m;\n    unsigned int n;\n    BN_ULONG l;\n    BIGNUM *bn = NULL;\n    if (ret == NULL)\n        ret = bn = BN_new();\n    if (ret == NULL)\n        return NULL;\n    bn_check_top(ret);\n    for ( ; len > 0 && *s == 0; s++, len--)\n        continue;\n    n = len;\n    if (n == 0) {\n        ret->top = 0;\n        return ret;\n    }\n    i = ((n - 1) / BN_BYTES) + 1;\n    m = ((n - 1) % (BN_BYTES));\n    if (bn_wexpand(ret, (int)i) == NULL) {\n        BN_free(bn);\n        return NULL;\n    }\n    ret->top = i;\n    ret->neg = 0;\n    l = 0;\n    while (n--) {\n        l = (l << 8L) | *(s++);\n        if (m-- == 0) {\n            ret->d[--i] = l;\n            l = 0;\n            m = BN_BYTES - 1;\n        }\n    }\n    bn_correct_top(ret);\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 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    if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n        rr->top = max - 1;\n    else\n        rr->top = max;\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}']