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


crypto/bn/bntest.c:1359:1: Parameter `ctx->stack.depth`
1357.   	}
1358.   
1359. > int test_gf2m_mod_sqrt(BIO *bp,BN_CTX *ctx)
1360.   	{
1361.   	BIGNUM *a,*b[2],*c,*d,*e,*f;

crypto/bn/bntest.c:1383:4: Call
1381.   			{
1382.   			BN_GF2m_mod(c, a, b[j]);
1383.   			BN_GF2m_mod_sqrt(d, a, b[j], ctx);
           ^
1384.   			BN_GF2m_mod_sqr(e, d, b[j], ctx);
1385.   #if 0 /* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic */

crypto/bn/bn_gf2m.c:894:1: Parameter `ctx->stack.depth`
  892.    * BN_GF2m_mod_sqrt_arr function.
  893.    */
  894. > int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
  895.   	{
  896.   	int ret = 0;

crypto/bn/bntest.c:1384:4: Call
1382.   			BN_GF2m_mod(c, a, b[j]);
1383.   			BN_GF2m_mod_sqrt(d, a, b[j], ctx);
1384.   			BN_GF2m_mod_sqr(e, d, b[j], ctx);
           ^
1385.   #if 0 /* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic */
1386.   			if (bp != NULL)

crypto/bn/bn_gf2m.c:551:1: Parameter `ctx->stack.depth`
  549.    * BN_GF2m_mod_sqr_arr function.
  550.    */
  551. > int	BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
  552.   	{
  553.   	int ret = 0;

crypto/bn/bn_gf2m.c:566:8: Call
  564.   		goto err;
  565.   		}
  566.   	ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
                ^
  567.   	bn_check_top(r);
  568.   err:

crypto/bn/bn_gf2m.c:519:1: Parameter `ctx->stack.depth`
    517.   
    518.   /* Square a, reduce the result mod p, and store it in a.  r could be a. */
    519. > int	BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], BN_CTX *ctx)
    520.   	{
    521.   	int i, ret = 0;

crypto/bn/bn_gf2m.c:525:2: Call
    523.   
    524.   	bn_check_top(a);
    525.   	BN_CTX_start(ctx);
            ^
    526.   	if ((s = BN_CTX_get(ctx)) == NULL) return 0;
    527.   	if (!bn_wexpand(s, 2 * a->top)) goto err;

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

crypto/bn/bn_gf2m.c:541:2: Call
    539.   	ret = 1;
    540.   err:
    541.   	BN_CTX_end(ctx);
            ^
    542.   	return ret;
    543.   	}

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

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

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

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

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

static unsigned int BN_STACK_pop(BN_STACK *st)
	{
	return st->indexes[--(st->depth)];
	}
['int test_gf2m_mod_sqrt(BIO *bp,BN_CTX *ctx)\n\t{\n\tBIGNUM *a,*b[2],*c,*d,*e,*f;\n\tint i, j, ret = 0;\n\tunsigned int p0[] = {163,7,6,3,0};\n\tunsigned int p1[] = {193,15,0};\n\ta=BN_new();\n\tb[0]=BN_new();\n\tb[1]=BN_new();\n\tc=BN_new();\n\td=BN_new();\n\te=BN_new();\n\tf=BN_new();\n\tBN_GF2m_arr2poly(p0, b[0]);\n\tBN_GF2m_arr2poly(p1, b[1]);\n\tfor (i=0; i<num0; i++)\n\t\t{\n\t\tBN_bntest_rand(a, 512, 0, 0);\n\t\tfor (j=0; j < 2; j++)\n\t\t\t{\n\t\t\tBN_GF2m_mod(c, a, b[j]);\n\t\t\tBN_GF2m_mod_sqrt(d, a, b[j], ctx);\n\t\t\tBN_GF2m_mod_sqr(e, d, b[j], ctx);\n#if 0\n\t\t\tif (bp != NULL)\n\t\t\t\t{\n\t\t\t\tif (!results)\n\t\t\t\t\t{\n\t\t\t\t\tBN_print(bp,d);\n\t\t\t\t\tBIO_puts(bp, " ^ 2 - ");\n\t\t\t\t\tBN_print(bp,a);\n\t\t\t\t\tBIO_puts(bp,"\\n");\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\t\t\tBN_GF2m_add(f, c, e);\n\t\t\tif(!BN_is_zero(f))\n\t\t\t\t{\n\t\t\t\tfprintf(stderr,"GF(2^m) modular square root test failed!\\n");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tret = 1;\n  err:\n\tBN_free(a);\n\tBN_free(b[0]);\n\tBN_free(b[1]);\n\tBN_free(c);\n\tBN_free(d);\n\tBN_free(e);\n\tBN_free(f);\n\treturn ret;\n\t}', 'int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tint ret = 0;\n\tconst int max = BN_num_bits(p);\n\tunsigned int *arr=NULL;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tif ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;\n\tret = BN_GF2m_poly2arr(p, arr, max);\n\tif (!ret || ret > max)\n\t\t{\n\t\tBNerr(BN_F_BN_GF2M_MOD_EXP,BN_R_INVALID_LENGTH);\n\t\tgoto err;\n\t\t}\n\tret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx);\n\tbn_check_top(r);\nerr:\n\tif (arr) OPENSSL_free(arr);\n\treturn ret;\n\t}', 'int\tBN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tint ret = 0;\n\tconst int max = BN_num_bits(p);\n\tunsigned int *arr=NULL;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tif ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;\n\tret = BN_GF2m_poly2arr(p, arr, max);\n\tif (!ret || ret > max)\n\t\t{\n\t\tBNerr(BN_F_BN_GF2M_MOD_SQR,BN_R_INVALID_LENGTH);\n\t\tgoto err;\n\t\t}\n\tret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);\n\tbn_check_top(r);\nerr:\n\tif (arr) OPENSSL_free(arr);\n\treturn ret;\n\t}', 'int\tBN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], BN_CTX *ctx)\n\t{\n\tint i, ret = 0;\n\tBIGNUM *s;\n\tbn_check_top(a);\n\tBN_CTX_start(ctx);\n\tif ((s = BN_CTX_get(ctx)) == NULL) return 0;\n\tif (!bn_wexpand(s, 2 * a->top)) goto err;\n\tfor (i = a->top - 1; i >= 0; i--)\n\t\t{\n\t\ts->d[2*i+1] = SQR1(a->d[i]);\n\t\ts->d[2*i  ] = SQR0(a->d[i]);\n\t\t}\n\ts->top = 2 * a->top;\n\tbn_correct_top(s);\n\tif (!BN_GF2m_mod_arr(r, s, p)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\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_GET,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}']