crypto/bn/bntest.c:708: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_sqr`.
Showing all 11 steps of the trace


crypto/bn/bntest.c:690:1: Parameter `ctx->stack.depth`
688.   	}
689.   
690. > int test_sqr(BIO *bp, BN_CTX *ctx)
691.   	{
692.   	BIGNUM *a,*c,*d,*e;

crypto/bn/bntest.c:708:3: Call
706.   		BN_bntest_rand(a,40+i*10,0,0);
707.   		a->neg=rand_neg();
708.   		BN_sqr(c,a,ctx);
         ^
709.   		if (bp != NULL)
710.   			{

crypto/bn/bn_sqr.c:64:1: Parameter `ctx->stack.depth`
  62.   /* r must not be a */
  63.   /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
  64. > int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
  65.   	{
  66.   	int max,al;

crypto/bn/bn_sqr.c:80:2: Call
  78.   		}
  79.   
  80.   	BN_CTX_start(ctx);
         ^
  81.   	rr=(a != r) ? r : BN_CTX_get(ctx);
  82.   	tmp=BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:257:1: Parameter `ctx->stack.depth`
    255.   	}
    256.   
    257. > void BN_CTX_start(BN_CTX *ctx)
    258.   	{
    259.   	CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_sqr.c:150:2: Call
  148.   	bn_check_top(rr);
  149.   	bn_check_top(tmp);
  150.   	BN_CTX_end(ctx);
          ^
  151.   	return(ret);
  152.   	}

crypto/bn/bn_ctx.c:272:1: Parameter `ctx->stack.depth`
    270.   	}
    271.   
    272. > void BN_CTX_end(BN_CTX *ctx)
    273.   	{
    274.   	CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:279:21: Call
    277.   	else
    278.   		{
    279.   		unsigned int fp = BN_STACK_pop(&ctx->stack);
                               ^
    280.   		/* Does this stack frame have anything to release? */
    281.   		if(fp < ctx->used)

crypto/bn/bn_ctx.c:353:1: <LHS trace>
351.   	}
352.   
353. > static unsigned int BN_STACK_pop(BN_STACK *st)
354.   	{
355.   	return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:353:1: Parameter `st->depth`
      351.   	}
      352.   
      353. > static unsigned int BN_STACK_pop(BN_STACK *st)
      354.   	{
      355.   	return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:355:9: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_sqr` 
      353.   static unsigned int BN_STACK_pop(BN_STACK *st)
      354.   	{
      355.   	return st->indexes[--(st->depth)];
                     ^
      356.   	}
      357.   

static unsigned int BN_STACK_pop(BN_STACK *st)
	{
	return st->indexes[--(st->depth)];
	}
['int test_sqr(BIO *bp, BN_CTX *ctx)\n\t{\n\tBIGNUM *a,*c,*d,*e;\n\tint i, ret = 0;\n\ta = BN_new();\n\tc = BN_new();\n\td = BN_new();\n\te = BN_new();\n\tif (a == NULL || c == NULL || d == NULL || e == NULL)\n\t\t{\n\t\tgoto err;\n\t\t}\n\tfor (i=0; i<num0; i++)\n\t\t{\n\t\tBN_bntest_rand(a,40+i*10,0,0);\n\t\ta->neg=rand_neg();\n\t\tBN_sqr(c,a,ctx);\n\t\tif (bp != NULL)\n\t\t\t{\n\t\t\tif (!results)\n\t\t\t\t{\n\t\t\t\tBN_print(bp,a);\n\t\t\t\tBIO_puts(bp," * ");\n\t\t\t\tBN_print(bp,a);\n\t\t\t\tBIO_puts(bp," - ");\n\t\t\t\t}\n\t\t\tBN_print(bp,c);\n\t\t\tBIO_puts(bp,"\\n");\n\t\t\t}\n\t\tBN_div(d,e,c,a,ctx);\n\t\tBN_sub(d,d,a);\n\t\tif(!BN_is_zero(d) || !BN_is_zero(e))\n\t\t\t{\n\t\t\tfprintf(stderr,"Square test failed!\\n");\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tBN_hex2bn(&a,\n\t\t"80000000000000008000000000000001FFFFFFFFFFFFFFFE0000000000000000");\n\tBN_sqr(c, a, ctx);\n\tif (bp != NULL)\n\t\t{\n\t\tif (!results)\n\t\t\t{\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," * ");\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," - ");\n\t\t\t}\n\t\tBN_print(bp,c);\n\t\tBIO_puts(bp,"\\n");\n\t\t}\n\tBN_mul(d, a, a, ctx);\n\tif (BN_cmp(c, d))\n\t\t{\n\t\tfprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "\n\t\t\t"different results!\\n");\n\t\tgoto err;\n\t\t}\n\tBN_hex2bn(&a,\n\t\t"80000000000000000000000080000001FFFFFFFE000000000000000000000000");\n\tBN_sqr(c, a, ctx);\n\tif (bp != NULL)\n\t\t{\n\t\tif (!results)\n\t\t\t{\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," * ");\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," - ");\n\t\t\t}\n\t\tBN_print(bp,c);\n\t\tBIO_puts(bp,"\\n");\n\t\t}\n\tBN_mul(d, a, a, ctx);\n\tif (BN_cmp(c, d))\n\t\t{\n\t\tfprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "\n\t\t\t"different results!\\n");\n\t\tgoto err;\n\t\t}\n\tret = 1;\nerr:\n\tif (a != NULL) BN_free(a);\n\tif (c != NULL) BN_free(c);\n\tif (d != NULL) BN_free(d);\n\tif (e != NULL) BN_free(e);\n\treturn ret;\n\t}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n\t{\n\tint max,al;\n\tint ret = 0;\n\tBIGNUM *tmp,*rr;\n\tbn_check_top(a);\n\tal=a->top;\n\tif (al <= 0)\n\t\t{\n\t\tr->top=0;\n\t\tr->neg = 0;\n\t\treturn 1;\n\t\t}\n\tBN_CTX_start(ctx);\n\trr=(a != r) ? r : BN_CTX_get(ctx);\n\ttmp=BN_CTX_get(ctx);\n\tif (!rr || !tmp) goto err;\n\tmax = 2 * al;\n\tif (bn_wexpand(rr,max) == NULL) goto err;\n\tif (al == 4)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[8];\n\t\tbn_sqr_normal(rr->d,a->d,4,t);\n#else\n\t\tbn_sqr_comba4(rr->d,a->d);\n#endif\n\t\t}\n\telse if (al == 8)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[16];\n\t\tbn_sqr_normal(rr->d,a->d,8,t);\n#else\n\t\tbn_sqr_comba8(rr->d,a->d);\n#endif\n\t\t}\n\telse\n\t\t{\n#if defined(BN_RECURSION)\n\t\tif (al < BN_SQR_RECURSIVE_SIZE_NORMAL)\n\t\t\t{\n\t\t\tBN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2];\n\t\t\tbn_sqr_normal(rr->d,a->d,al,t);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tint j,k;\n\t\t\tj=BN_num_bits_word((BN_ULONG)al);\n\t\t\tj=1<<(j-1);\n\t\t\tk=j+j;\n\t\t\tif (al == j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,k*2) == NULL) goto err;\n\t\t\t\tbn_sqr_recursive(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\t\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\t}\n#else\n\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n#endif\n\t\t}\n\trr->neg=0;\n\tif(a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n\t\trr->top = max - 1;\n\telse\n\t\trr->top = max;\n\tif (rr != r) BN_copy(r,rr);\n\tret = 1;\n err:\n\tbn_check_top(rr);\n\tbn_check_top(tmp);\n\tBN_CTX_end(ctx);\n\treturn(ret);\n\t}', 'void BN_CTX_start(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_start", ctx);\n\tif(ctx->err_stack || ctx->too_many)\n\t\tctx->err_stack++;\n\telse if(!BN_STACK_push(&ctx->stack, ctx->used))\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_START,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\tctx->err_stack++;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}', 'void BN_CTX_end(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_end", ctx);\n\tif(ctx->err_stack)\n\t\tctx->err_stack--;\n\telse\n\t\t{\n\t\tunsigned int fp = BN_STACK_pop(&ctx->stack);\n\t\tif(fp < ctx->used)\n\t\t\tBN_POOL_release(&ctx->pool, ctx->used - fp);\n\t\tctx->used = fp;\n\t\tctx->too_many = 0;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n\t{\n\treturn st->indexes[--(st->depth)];\n\t}']