test/bntest.c:1198: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 67108856] by call to `BN_sqr`.
Showing all 29 steps of the trace


test/bntest.c:1184:17: Call
1182.   static int file_square(STANZA *s)
1183.   {
1184.       BIGNUM *a = getBN(s, "A");
                        ^
1185.       BIGNUM *square = getBN(s, "Square");
1186.       BIGNUM *zero = BN_new();

test/bntest.c:115:9: Call
  113.       }
  114.   
  115.       if (parseBN(&ret, hex) != (int)strlen(hex)) {
                 ^
  116.           fprintf(stderr, "Could not decode '%s'.\n", hex);
  117.           return NULL;

test/bntest.c:95:12: Call
    93.   {
    94.       *out = NULL;
    95.       return BN_hex2bn(out, in);
                     ^
    96.   }
    97.   

crypto/bn/bn_print.c:166:5: Assignment
      164.       j = i;                      /* least significant 'hex' */
      165.       m = 0;
      166.       h = 0;
                 ^
      167.       while (j > 0) {
      168.           m = ((BN_BYTES * 2) <= j) ? (BN_BYTES * 2) : j;

crypto/bn/bn_print.c:184:5: Assignment
      182.           j -= (BN_BYTES * 2);
      183.       }
      184.       ret->top = h;
                 ^
      185.       bn_correct_top(ret);
      186.   

test/bntest.c:1198:10: Call
1196.       BN_zero(zero);
1197.   
1198.       if (!BN_sqr(ret, a, ctx)
                 ^
1199.               || !equalBN("A^2", square, ret)
1200.               || !BN_mul(ret, a, a, ctx)

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:38:5: Assignment
  36.           goto err;
  37.   
  38.       max = 2 * al;               /* Non-zero (from above) */
            ^
  39.       if (bn_wexpand(rr, max) == NULL)
  40.           goto err;

crypto/bn/bn_sqr.c:90:9: Assignment
  88.        */
  89.       if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))
  90.           rr->top = max - 1;
                ^
  91.       else
  92.           rr->top = max;

crypto/bn/bn_sqr.c:93:20: Call
  91.       else
  92.           rr->top = max;
  93.       if (r != rr && BN_copy(r, rr) == NULL)
                           ^
  94.           goto err;
  95.   

crypto/bn/bn_lib.c:322:1: Parameter `a->top`
    320.   }
    321.   
    322. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
    323.   {
    324.       bn_check_top(b);

crypto/bn/bn_lib.c:328:9: Call
    326.       if (a == b)
    327.           return a;
    328.       if (bn_wexpand(a, b->top) == NULL)
                   ^
    329.           return NULL;
    330.   

crypto/bn/bn_lib.c:946:1: Parameter `a->top`
      944.   }
      945.   
      946. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
      947.   {
      948.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:948:37: Call
      946.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
      947.   {
      948.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                                 ^
      949.   }
      950.   

crypto/bn/bn_lib.c:283:1: Parameter `b->top`
        281.    */
        282.   
        283. > BIGNUM *bn_expand2(BIGNUM *b, int words)
        284.   {
        285.       bn_check_top(b);

crypto/bn/bn_lib.c:288:23: Call
        286.   
        287.       if (words > b->dmax) {
        288.           BN_ULONG *a = bn_expand_internal(b, words);
                                     ^
        289.           if (!a)
        290.               return NULL;

crypto/bn/bn_lib.c:246:1: <Offset trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `b->top`
          244.   /* This is used by bn_expand2() */
          245.   /* The caller MUST check that words > b->dmax before calling this */
          246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
          247.   {
          248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: <Length trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `words`
          244.   /* This is used by bn_expand2() */
          245.   /* The caller MUST check that words > b->dmax before calling this */
          246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
          247.   {
          248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:263:13: Call
          261.           a = OPENSSL_secure_zalloc(words * sizeof(*a));
          262.       else
          263.           a = OPENSSL_zalloc(words * sizeof(*a));
                             ^
          264.       if (a == NULL) {
          265.           BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);

crypto/mem.c:186:1: Parameter `num`
            184.   }
            185.   
            186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
            187.   {
            188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:17: Call
            186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
            187.   {
            188.       void *ret = CRYPTO_malloc(num, file, line);
                                   ^
            189.   
            190.       FAILTEST();

crypto/mem.c:166:9: Assignment
              164.   
              165.       if (num == 0)
              166.           return NULL;
                             ^
              167.   
              168.       FAILTEST();

crypto/mem.c:188:5: Assignment
            186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
            187.   {
            188.       void *ret = CRYPTO_malloc(num, file, line);
                       ^
            189.   
            190.       FAILTEST();

crypto/mem.c:193:5: Assignment
            191.       if (ret != NULL)
            192.           memset(ret, 0, num);
            193.       return ret;
                       ^
            194.   }
            195.   

crypto/bn/bn_lib.c:263:9: Assignment
          261.           a = OPENSSL_secure_zalloc(words * sizeof(*a));
          262.       else
          263.           a = OPENSSL_zalloc(words * sizeof(*a));
                         ^
          264.       if (a == NULL) {
          265.           BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:270:5: Array access: Offset added: [8, +oo] Size: [0, 67108856] by call to `BN_sqr` 
          268.   
          269.       assert(b->top <= words);
          270.       memcpy(a, b->d, sizeof(*a) * b->top);
                     ^
          271.   
          272.       return a;
