test/bntest.c:1818: error: BUFFER_OVERRUN_L3
  Offset: [16, +oo] (⇐ 1 + [15, +oo]) Size: [0, 8388607] by call to `BN_mod_sqrt`.
Showing all 44 steps of the trace


test/bntest.c:1781:18: Call
1779.               unsigned primes[8] = { 2, 3, 5, 7, 11, 13, 17, 19 };
1780.   
1781.               if (!BN_set_word(p, primes[i]))
                         ^
1782.                   goto err;
1783.           } else {

crypto/bn/bn_lib.c:463:1: Parameter `a->top`
  461.   }
  462.   
  463. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  464.   {
  465.       bn_check_top(a);

test/bntest.c:1818:18: Call
1816.                       goto err;
1817.   
1818.               if (!BN_mod_sqrt(r, a, p, ctx))
                         ^
1819.                   goto err;
1820.               if (!BN_mod_sqr(r, r, p, ctx))

crypto/bn/bn_sqrt.c:13:1: Parameter `p->top`
  11.   #include "bn_lcl.h"
  12.   
  13. > BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
  14.   /*
  15.    * Returns 'ret' such that ret^2 == a (mod p), using the Tonelli/Shanks

crypto/bn/bn_sqrt.c:26:10: Call
  24.       int e, i, j;
  25.   
  26.       if (!BN_is_odd(p) || BN_abs_is_word(p, 1)) {
                 ^
  27.           if (BN_abs_is_word(p, 2)) {
  28.               if (ret == NULL)

crypto/bn/bn_lib.c:935:1: Parameter `a->top`
    933.   }
    934.   
    935. > int BN_is_odd(const BIGNUM *a)
    936.   {
    937.       return (a->top > 0) && (a->d[0] & 1);

crypto/bn/bn_sqrt.c:26:26: Call
  24.       int e, i, j;
  25.   
  26.       if (!BN_is_odd(p) || BN_abs_is_word(p, 1)) {
                                 ^
  27.           if (BN_abs_is_word(p, 2)) {
  28.               if (ret == NULL)

crypto/bn/bn_lib.c:915:1: Parameter `a->top`
    913.   }
    914.   
    915. > int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    916.   {
    917.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));

crypto/bn/bn_sqrt.c:75:10: Call
  73.   
  74.       /* A = a mod p */
  75.       if (!BN_nnmod(A, a, p, ctx))
                 ^
  76.           goto end;
  77.   

crypto/bn/bn_mod.c:13:1: Parameter `d->top`
    11.   #include "bn_lcl.h"
    12.   
    13. > int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
    14.   {
    15.       /*

crypto/bn/bn_mod.c:20:11: Call
    18.        */
    19.   
    20.       if (!(BN_mod(r, m, d, ctx)))
                    ^
    21.           return 0;
    22.       if (!r->neg)

crypto/bn/bn_div.c:140:1: Parameter `divisor->top`
      138.    * If 'dv' or 'rm' is NULL, the respective value is not returned.
      139.    */
      140. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
      141.              BN_CTX *ctx)
      142.   {

crypto/bn/bn_sqrt.c:80:13: Call
  78.       /* now write  |p| - 1  as  2^e*q  where  q  is odd */
  79.       e = 1;
  80.       while (!BN_is_bit_set(p, e))
                    ^
  81.           e++;
  82.       /* we'll set  q  later (if needed) */

crypto/bn/bn_lib.c:732:1: Parameter `a->top`
    730.   }
    731.   
    732. > int BN_is_bit_set(const BIGNUM *a, int n)
    733.   {
    734.       int i, j;

crypto/bn/bn_sqrt.c:93:14: Call
  91.            * so we can use exponent  (|p|+1)/4,  i.e.  (|p|-3)/4 + 1.
  92.            */
  93.           if (!BN_rshift(q, p, 2))
                     ^
  94.               goto end;
  95.           q->neg = 0;

crypto/bn/bn_shift.c:120:1: Parameter `a->top`
    118.   }
    119.   
    120. > int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
    121.   {
    122.       int i, j, nw, lb, rb;

crypto/bn/bn_sqrt.c:98:14: Call
  96.           if (!BN_add_word(q, 1))
  97.               goto end;
  98.           if (!BN_mod_exp(ret, A, q, p, ctx))
                      ^
  99.               goto end;
  100.           err = 0;

crypto/bn/bn_exp.c:91:1: Parameter `m->top`
    89.   }
    90.   
    91. > int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
    92.                  BN_CTX *ctx)
    93.   {

crypto/bn/bn_exp.c:143:9: Call
    141.       /* if ((m->d[m->top-1]&BN_TBIT) && BN_is_odd(m)) */
    142.   
    143.       if (BN_is_odd(m)) {
                   ^
    144.   # ifdef MONT_EXP_WORD
    145.           if (a->top == 1 && !a->neg

crypto/bn/bn_lib.c:935:1: Parameter `a->top`
      933.   }
      934.   
      935. > int BN_is_odd(const BIGNUM *a)
      936.   {
      937.       return (a->top > 0) && (a->d[0] & 1);

crypto/bn/bn_exp.c:151:19: Call
    149.           } else
    150.   # endif
    151.               ret = BN_mod_exp_mont(r, a, p, m, ctx, NULL);
                             ^
    152.       } else
    153.   #endif

crypto/bn/bn_exp.c:301:1: Parameter `m->top`
      299.   }
      300.   
      301. > int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
      302.                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
      303.   {

crypto/bn/bn_exp.c:313:16: Call
      311.   
      312.       if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) {
      313.           return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);
                            ^
      314.       }
      315.   

crypto/bn/bn_exp.c:744:14: Assignment
        742.           /* 2^(top*BN_BITS2) - m */
        743.           tmp.d[0] = (0 - m->d[0]) & BN_MASK2;
        744.           for (i = 1; i < top; i++)
                            ^
        745.               tmp.d[i] = (~m->d[i]) & BN_MASK2;
        746.           tmp.top = top;

crypto/bn/bn_exp.c:1043:14: Call
        1041.           for (wvalue = 0, i = bits % window; i >= 0; i--, bits--)
        1042.               wvalue = (wvalue << 1) + BN_is_bit_set(p, bits);
        1043.           if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf, wvalue,
                             ^
        1044.                                               window))
        1045.               goto err;

crypto/bn/bn_exp.c:525:1: Parameter `top`
          523.   }
          524.   
          525. > static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top,
          526.                                             unsigned char *buf, int idx,
          527.                                             int window)

crypto/bn/bn_exp.c:582:5: Assignment
          580.       }
          581.   
          582.       b->top = top;
                     ^
          583.       bn_correct_top(b);
          584.       return 1;

crypto/bn/bn_exp.c:583:5: Call
          581.   
          582.       b->top = top;
          583.       bn_correct_top(b);
                     ^
          584.       return 1;
          585.   }

crypto/bn/bn_lib.c:1021:1: Parameter `a->top`
            1019.   }
            1020.   
            1021. > void bn_correct_top(BIGNUM *a)
            1022.   {
            1023.       BN_ULONG *ftl;

crypto/bn/bn_exp.c:1056:22: Call
        1054.               /* Scan the window, squaring the result as we go */
        1055.               for (i = 0; i < window; i++, bits--) {
        1056.                   if (!BN_mod_mul_montgomery(&tmp, &tmp, &tmp, mont, ctx))
                                     ^
        1057.                       goto err;
        1058.                   wvalue = (wvalue << 1) + BN_is_bit_set(p, bits);

crypto/bn/bn_mont.c:26:1: Parameter `a->top`
          24.   #endif
          25.   
          26. > int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
          27.                             BN_MONT_CTX *mont, BN_CTX *ctx)
          28.   {

crypto/bn/bn_mont.c:53:14: Call
          51.       bn_check_top(tmp);
          52.       if (a == b) {
          53.           if (!BN_sqr(tmp, a, ctx))
                             ^
          54.               goto err;
          55.       } 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_sqrt` 
              118.       if (--j > 0) {
              119.           ap++;
              120.           rp[j] = bn_mul_words(rp, ap, j, ap[-1]);
                             ^
              121.           rp += 2;
              122.       }
