crypto/bn/bn_blind.c:265: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_BLINDING_update`.
Showing all 17 steps of the trace


crypto/bn/bn_blind.c:259:9: Call
257.   
258.   	if (r != NULL)
259.   		ret = BN_mod_mul(n, n, r, b->mod, ctx);
               ^
260.   	else
261.   		ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);

crypto/bn/bn_mod.c:200:2: Call
  198.   	ret=1;
  199.   err:
  200.   	BN_CTX_end(ctx);
          ^
  201.   	return(ret);
  202.   	}

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

crypto/bn/bn_blind.c:265:8: Call
263.   	if (ret >= 0)
264.   		{
265.   		if (!BN_BLINDING_update(b,ctx))
              ^
266.   			return(0);
267.   		}

crypto/bn/bn_blind.c:185:1: Parameter `ctx->pool.used`
  183.   	}
  184.   
  185. > int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)
  186.   	{
  187.   	int ret=0;

crypto/bn/bn_blind.c:204:8: Call
  202.   	else if (!(b->flags & BN_BLINDING_NO_UPDATE))
  203.   		{
  204.   		if (!BN_mod_mul(b->A,b->A,b->A,b->mod,ctx)) goto err;
                ^
  205.   		if (!BN_mod_mul(b->Ai,b->Ai,b->Ai,b->mod,ctx)) goto err;
  206.   		}

crypto/bn/bn_mod.c:180:1: Parameter `ctx->pool.used`
    178.   
    179.   /* slow but works */
    180. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
    181.   	BN_CTX *ctx)
    182.   	{

crypto/bn/bn_mod.c:191:11: Call
    189.   
    190.   	BN_CTX_start(ctx);
    191.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
                     ^
    192.   	if (a == b)
    193.   		{ if (!BN_sqr(t,a,ctx)) goto err; }

crypto/bn/bn_ctx.c:290:1: Parameter `ctx->pool.used`
      288.   	}
      289.   
      290. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
      291.   	{
      292.   	BIGNUM *ret;

crypto/bn/bn_mod.c:195:10: Call
    193.   		{ if (!BN_sqr(t,a,ctx)) goto err; }
    194.   	else
    195.   		{ if (!BN_mul(t,a,b,ctx)) goto err; }
                    ^
    196.   	if (!BN_nnmod(r,t,m,ctx)) goto err;
    197.   	bn_check_top(r);

crypto/bn/bn_mul.c:943:1: Parameter `ctx->pool.used`
      941.   #endif /* BN_RECURSION */
      942.   
      943. > int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
      944.   	{
      945.   	int ret=0;

crypto/bn/bn_mul.c:1100:2: Call
      1098.   err:
      1099.   	bn_check_top(r);
      1100.   	BN_CTX_end(ctx);
               ^
      1101.   	return(ret);
      1102.   	}

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

crypto/bn/bn_ctx.c:282:4: Call
        280.   		/* Does this stack frame have anything to release? */
        281.   		if(fp < ctx->used)
        282.   			BN_POOL_release(&ctx->pool, ctx->used - fp);
                  ^
        283.   		ctx->used = fp;
        284.   		/* Unjam "too_many" in case "get" had failed */

crypto/bn/bn_ctx.c:440:1: <LHS trace>
438.   	}
439.   
440. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
441.   	{
442.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:440:1: Parameter `p->used`
          438.   	}
          439.   
          440. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
          441.   	{
          442.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:442:2: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_BLINDING_update` 
          440.   static void BN_POOL_release(BN_POOL *p, unsigned int num)
          441.   	{
          442.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
                  ^
          443.   	p->used -= num;
          444.   	while(num--)

static void BN_POOL_release(BN_POOL *p, unsigned int num)
	{
	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
	p->used -= num;
	while(num--)
		{
		bn_check_top(p->current->vals + offset);
		if(!offset)
			{
			offset = BN_CTX_POOL_SIZE - 1;
			p->current = p->current->prev;
			}
		else
			offset--;
		}
	}
['int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)\n\t{\n\tint ret;\n\tbn_check_top(n);\n\tif ((b->A == NULL) || (b->Ai == NULL))\n\t\t{\n\t\tBNerr(BN_F_BN_BLINDING_INVERT_EX,BN_R_NOT_INITIALIZED);\n\t\treturn(0);\n\t\t}\n\tif (r != NULL)\n\t\tret = BN_mod_mul(n, n, r, b->mod, ctx);\n\telse\n\t\tret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);\n\tif (ret >= 0)\n\t\t{\n\t\tif (!BN_BLINDING_update(b,ctx))\n\t\t\treturn(0);\n\t\t}\n\tbn_check_top(n);\n\treturn(ret);\n\t}', 'int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n\tBN_CTX *ctx)\n\t{\n\tBIGNUM *t;\n\tint ret=0;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(m);\n\tBN_CTX_start(ctx);\n\tif ((t = BN_CTX_get(ctx)) == NULL) goto err;\n\tif (a == b)\n\t\t{ if (!BN_sqr(t,a,ctx)) goto err; }\n\telse\n\t\t{ if (!BN_mul(t,a,b,ctx)) goto err; }\n\tif (!BN_nnmod(r,t,m,ctx)) goto err;\n\tbn_check_top(r);\n\tret=1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn(ret);\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}', 'int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)\n\t{\n\tint ret=0;\n\tif ((b->A == NULL) || (b->Ai == NULL))\n\t\t{\n\t\tBNerr(BN_F_BN_BLINDING_UPDATE,BN_R_NOT_INITIALIZED);\n\t\tgoto err;\n\t\t}\n\tif (--(b->counter) == 0 && b->e != NULL &&\n\t\t!(b->flags & BN_BLINDING_NO_RECREATE))\n\t\t{\n\t\tif (!BN_BLINDING_create_param(b, NULL, NULL, ctx, NULL, NULL))\n\t\t\tgoto err;\n\t\t}\n\telse if (!(b->flags & BN_BLINDING_NO_UPDATE))\n\t\t{\n\t\tif (!BN_mod_mul(b->A,b->A,b->A,b->mod,ctx)) goto err;\n\t\tif (!BN_mod_mul(b->Ai,b->Ai,b->Ai,b->mod,ctx)) goto err;\n\t\t}\n\tret=1;\nerr:\n\tif (b->counter == 0)\n\t\tb->counter = BN_BLINDING_COUNTER;\n\treturn(ret);\n\t}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n\t{\n\tBIGNUM *ret;\n\tCTXDBG_ENTRY("BN_CTX_get", ctx);\n\tif(ctx->err_stack || ctx->too_many) return NULL;\n\tif((ret = BN_POOL_get(&ctx->pool)) == NULL)\n\t\t{\n\t\tctx->too_many = 1;\n\t\tBNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\treturn NULL;\n\t\t}\n\tBN_zero(ret);\n\tctx->used++;\n\tCTXDBG_RET(ctx, ret);\n\treturn ret;\n\t}', 'int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n\t{\n\tint ret=0;\n\tint top,al,bl;\n\tBIGNUM *rr;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n\tint i;\n#endif\n#ifdef BN_RECURSION\n\tBIGNUM *t=NULL;\n\tint j=0,k;\n#endif\n#ifdef BN_COUNT\n\tfprintf(stderr,"BN_mul %d * %d\\n",a->top,b->top);\n#endif\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(r);\n\tal=a->top;\n\tbl=b->top;\n\tif ((al == 0) || (bl == 0))\n\t\t{\n\t\tBN_zero(r);\n\t\treturn(1);\n\t\t}\n\ttop=al+bl;\n\tBN_CTX_start(ctx);\n\tif ((r == a) || (r == b))\n\t\t{\n\t\tif ((rr = BN_CTX_get(ctx)) == NULL) goto err;\n\t\t}\n\telse\n\t\trr = r;\n\trr->neg=a->neg^b->neg;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n\ti = al-bl;\n#endif\n#ifdef BN_MUL_COMBA\n\tif (i == 0)\n\t\t{\n# if 0\n\t\tif (al == 4)\n\t\t\t{\n\t\t\tif (bn_wexpand(rr,8) == NULL) goto err;\n\t\t\trr->top=8;\n\t\t\tbn_mul_comba4(rr->d,a->d,b->d);\n\t\t\tgoto end;\n\t\t\t}\n# endif\n\t\tif (al == 8)\n\t\t\t{\n\t\t\tif (bn_wexpand(rr,16) == NULL) goto err;\n\t\t\trr->top=16;\n\t\t\tbn_mul_comba8(rr->d,a->d,b->d);\n\t\t\tgoto end;\n\t\t\t}\n\t\t}\n#endif\n#ifdef BN_RECURSION\n\tif ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))\n\t\t{\n\t\tif (i >= -1 && i <= 1)\n\t\t\t{\n\t\t\tif (i >= 0)\n\t\t\t\t{\n\t\t\t\tj = BN_num_bits_word((BN_ULONG)al);\n\t\t\t\t}\n\t\t\tif (i == -1)\n\t\t\t\t{\n\t\t\t\tj = BN_num_bits_word((BN_ULONG)bl);\n\t\t\t\t}\n\t\t\tj = 1<<(j-1);\n\t\t\tassert(j <= al || j <= bl);\n\t\t\tk = j+j;\n\t\t\tt = BN_CTX_get(ctx);\n\t\t\tif (t == NULL)\n\t\t\t\tgoto err;\n\t\t\tif (al > j || bl > j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(t,k*4) == NULL) goto err;\n\t\t\t\tif (bn_wexpand(rr,k*4) == NULL) goto err;\n\t\t\t\tbn_mul_part_recursive(rr->d,a->d,b->d,\n\t\t\t\t\tj,al-j,bl-j,t->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(t,k*2) == NULL) goto err;\n\t\t\t\tif (bn_wexpand(rr,k*2) == NULL) goto err;\n\t\t\t\tbn_mul_recursive(rr->d,a->d,b->d,\n\t\t\t\t\tj,al-j,bl-j,t->d);\n\t\t\t\t}\n\t\t\trr->top=top;\n\t\t\tgoto end;\n\t\t\t}\n#if 0\n\t\tif (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))\n\t\t\t{\n\t\t\tBIGNUM *tmp_bn = (BIGNUM *)b;\n\t\t\tif (bn_wexpand(tmp_bn,al) == NULL) goto err;\n\t\t\ttmp_bn->d[bl]=0;\n\t\t\tbl++;\n\t\t\ti--;\n\t\t\t}\n\t\telse if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))\n\t\t\t{\n\t\t\tBIGNUM *tmp_bn = (BIGNUM *)a;\n\t\t\tif (bn_wexpand(tmp_bn,bl) == NULL) goto err;\n\t\t\ttmp_bn->d[al]=0;\n\t\t\tal++;\n\t\t\ti++;\n\t\t\t}\n\t\tif (i == 0)\n\t\t\t{\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\tt = BN_CTX_get(ctx);\n\t\t\tif (al == j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(t,k*2) == NULL) goto err;\n\t\t\t\tif (bn_wexpand(rr,k*2) == NULL) goto err;\n\t\t\t\tbn_mul_recursive(rr->d,a->d,b->d,al,t->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(t,k*4) == NULL) goto err;\n\t\t\t\tif (bn_wexpand(rr,k*4) == NULL) goto err;\n\t\t\t\tbn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);\n\t\t\t\t}\n\t\t\trr->top=top;\n\t\t\tgoto end;\n\t\t\t}\n#endif\n\t\t}\n#endif\n\tif (bn_wexpand(rr,top) == NULL) goto err;\n\trr->top=top;\n\tbn_mul_normal(rr->d,a->d,al,b->d,bl);\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\nend:\n#endif\n\tbn_correct_top(rr);\n\tif (r != rr) BN_copy(r,rr);\n\tret=1;\nerr:\n\tbn_check_top(r);\n\tBN_CTX_end(ctx);\n\treturn(ret);\n\t}', 'static void BN_POOL_release(BN_POOL *p, unsigned int num)\n\t{\n\tunsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;\n\tp->used -= num;\n\twhile(num--)\n\t\t{\n\t\tbn_check_top(p->current->vals + offset);\n\t\tif(!offset)\n\t\t\t{\n\t\t\toffset = BN_CTX_POOL_SIZE - 1;\n\t\t\tp->current = p->current->prev;\n\t\t\t}\n\t\telse\n\t\t\toffset--;\n\t\t}\n\t}']