test/bntest.c:1559: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, 8388607] by call to `BN_mod_sqrt`.
Showing all 26 steps of the trace


test/bntest.c:1553:17: Call
1551.       if (!TEST_ptr(a = getBN(s, "A"))
1552.               || !TEST_ptr(p = getBN(s, "P"))
1553.               || !TEST_ptr(mod_sqrt = getBN(s, "ModSqrt"))
                        ^
1554.               || !TEST_ptr(ret = BN_new())
1555.               || !TEST_ptr(ret2 = BN_new()))

test/bntest.c:107:9: Call
  105.       }
  106.   
  107.       if (parseBN(&ret, hex) != (int)strlen(hex)) {
                 ^
  108.           TEST_error("Could not decode '%s'", hex);
  109.           return NULL;

test/bntest.c:88:12: Call
    86.   {
    87.       *out = NULL;
    88.       return BN_hex2bn(out, in);
                     ^
    89.   }
    90.   

crypto/bn/bn_print.c:126:1: Parameter `(*bn)->top`
      124.   }
      125.   
      126. > int BN_hex2bn(BIGNUM **bn, const char *a)
      127.   {
      128.       BIGNUM *ret = NULL;

test/bntest.c:1559:10: Call
1557.   
1558.       /* There are two possible answers. */
1559.       if (!TEST_true(BN_mod_sqrt(ret, a, p, ctx))
                 ^
1560.               || !TEST_true(BN_sub(ret2, p, ret)))
1561.           goto err;

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:858:1: Parameter `a->top`
    856.   }
    857.   
    858. > int BN_is_odd(const BIGNUM *a)
    859.   {
    860.       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:838:1: Parameter `a->top`
    836.   }
    837.   
    838. > int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    839.   {
    840.       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:250:31: Call
      248.   
      249.       /* First we normalise the numbers */
      250.       norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2);
                                           ^
      251.       if (!(BN_lshift(sdiv, divisor, norm_shift)))
      252.           goto err;

crypto/bn/bn_lib.c:141:9: Assignment
        139.   
        140.       if (BN_is_zero(a))
        141.           return 0;
                       ^
        142.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
        143.   }

crypto/bn/bn_div.c:250:5: Assignment
      248.   
      249.       /* First we normalise the numbers */
      250.       norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2);
                 ^
      251.       if (!(BN_lshift(sdiv, divisor, norm_shift)))
      252.           goto err;

crypto/bn/bn_div.c:251:11: Call
      249.       /* First we normalise the numbers */
      250.       norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2);
      251.       if (!(BN_lshift(sdiv, divisor, norm_shift)))
                       ^
      252.           goto err;
      253.       sdiv->neg = 0;

crypto/bn/bn_shift.c:83:1: <Offset trace>
81.   }
82.   
83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
84.   {
85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:83:1: Parameter `n`
        81.   }
        82.   
        83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
        84.   {
        85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:97:5: Assignment
        95.       }
        96.   
        97.       nw = n / BN_BITS2;
                   ^
        98.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
        99.           return 0;

crypto/bn/bn_shift.c:83:1: <Length trace>
81.   }
82.   
83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
84.   {
85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:83:1: Parameter `*r->d`
        81.   }
        82.   
        83. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
        84.   {
        85.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:98:9: Call
        96.   
        97.       nw = n / BN_BITS2;
        98.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
                       ^
        99.           return 0;
        100.       r->neg = a->neg;

crypto/bn/bn_lib.c:939:1: Parameter `*a->d`
          937.   }
          938.   
          939. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
          940.   {
          941.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_shift.c:104:5: Assignment
        102.       rb = BN_BITS2 - lb;
        103.       f = a->d;
        104.       t = r->d;
                   ^
        105.       t[a->top + nw] = 0;
        106.       if (lb == 0)

crypto/bn/bn_shift.c:112:13: Array access: Offset: [1, +oo] Size: [0, 8388607] by call to `BN_mod_sqrt` 
        110.           for (i = a->top - 1; i >= 0; i--) {
        111.               l = f[i];
        112.               t[nw + i + 1] |= (l >> rb) & BN_MASK2;
                           ^
        113.               t[nw + i] = (l << lb) & BN_MASK2;
        114.           }
