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


crypto/bn/bn_gf2m.c:698:7: Call
696.   	if (xinv == NULL) goto err;
697.   	
698.   	if (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err;
             ^
699.   	if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err;
700.   	bn_check_top(r);

crypto/bn/bn_gf2m.c:652:4: Call
  650.           bn_correct_top(v);
  651.   #endif
  652.     	BN_CTX_end(ctx);
            ^
  653.   	return ret;
  654.   	}

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_gf2m.c:699:7: Call
697.   	
698.   	if (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err;
699.   	if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err;
             ^
700.   	bn_check_top(r);
701.   	ret = 1;

crypto/bn/bn_gf2m.c:442:1: Parameter `ctx->pool.used`
  440.    * BN_GF2m_mod_mul_arr function.
  441.    */
  442. > int	BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)
  443.   	{
  444.   	int ret = 0;

crypto/bn/bn_gf2m.c:457:8: Call
  455.   		goto err;
  456.   		}
  457.   	ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
                ^
  458.   	bn_check_top(r);
  459.   err:

crypto/bn/bn_gf2m.c:389:1: Parameter `ctx->pool.used`
    387.    * the result in r.  r could be a or b; a could be b.
    388.    */
    389. > int	BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx)
    390.   	{
    391.   	int zlen, i, j, k, ret = 0;

crypto/bn/bn_gf2m.c:400:10: Call
    398.   	if (a == b)
    399.   		{
    400.   		return BN_GF2m_mod_sqr_arr(r, a, p, ctx);
                    ^
    401.   		}
    402.   

crypto/bn/bn_gf2m.c:466:1: Parameter `ctx->pool.used`
      464.   
      465.   /* Square a, reduce the result mod p, and store it in a.  r could be a. */
      466. > int	BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx)
      467.   	{
      468.   	int i, ret = 0;

crypto/bn/bn_gf2m.c:473:11: Call
      471.   	bn_check_top(a);
      472.   	BN_CTX_start(ctx);
      473.   	if ((s = BN_CTX_get(ctx)) == NULL) return 0;
                       ^
      474.   	if (!bn_wexpand(s, 2 * a->top)) goto err;
      475.   

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_gf2m.c:488:2: Call
      486.   	ret = 1;
      487.   err:
      488.   	BN_CTX_end(ctx);
              ^
      489.   	return ret;
      490.   	}

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_GF2m_mod_mul` 
          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_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tBIGNUM *xinv = NULL;\n\tint ret = 0;\n\tbn_check_top(y);\n\tbn_check_top(x);\n\tbn_check_top(p);\n\tBN_CTX_start(ctx);\n\txinv = BN_CTX_get(ctx);\n\tif (xinv == NULL) goto err;\n\tif (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err;\n\tif (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn ret;\n\t}', 'int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tBIGNUM *b, *c, *u, *v, *tmp;\n\tint ret = 0;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tBN_CTX_start(ctx);\n\tif ((b = BN_CTX_get(ctx))==NULL) goto err;\n\tif ((c = BN_CTX_get(ctx))==NULL) goto err;\n\tif ((u = BN_CTX_get(ctx))==NULL) goto err;\n\tif ((v = BN_CTX_get(ctx))==NULL) goto err;\n\tif (!BN_GF2m_mod(u, a, p)) goto err;\n\tif (BN_is_zero(u)) goto err;\n\tif (!BN_copy(v, p)) goto err;\n#if 0\n\tif (!BN_one(b)) goto err;\n\twhile (1)\n\t\t{\n\t\twhile (!BN_is_odd(u))\n\t\t\t{\n\t\t\tif (BN_is_zero(u)) goto err;\n\t\t\tif (!BN_rshift1(u, u)) goto err;\n\t\t\tif (BN_is_odd(b))\n\t\t\t\t{\n\t\t\t\tif (!BN_GF2m_add(b, b, p)) goto err;\n\t\t\t\t}\n\t\t\tif (!BN_rshift1(b, b)) goto err;\n\t\t\t}\n\t\tif (BN_abs_is_word(u, 1)) break;\n\t\tif (BN_num_bits(u) < BN_num_bits(v))\n\t\t\t{\n\t\t\ttmp = u; u = v; v = tmp;\n\t\t\ttmp = b; b = c; c = tmp;\n\t\t\t}\n\t\tif (!BN_GF2m_add(u, u, v)) goto err;\n\t\tif (!BN_GF2m_add(b, b, c)) goto err;\n\t\t}\n#else\n\t{\n\tint i,\tubits = BN_num_bits(u),\n\t\tvbits = BN_num_bits(v),\n\t\ttop = p->top;\n\tBN_ULONG *udp,*bdp,*vdp,*cdp;\n\tbn_wexpand(u,top);\tudp = u->d;\n\t\t\t\tfor (i=u->top;i<top;i++) udp[i] = 0;\n\t\t\t\tu->top = top;\n\tbn_wexpand(b,top);\tbdp = b->d;\n\t\t\t\tbdp[0] = 1;\n\t\t\t\tfor (i=1;i<top;i++) bdp[i] = 0;\n\t\t\t\tb->top = top;\n\tbn_wexpand(c,top);\tcdp = c->d;\n\t\t\t\tfor (i=0;i<top;i++) cdp[i] = 0;\n\t\t\t\tc->top = top;\n\tvdp = v->d;\n\twhile (1)\n\t\t{\n\t\twhile (ubits && !(udp[0]&1))\n\t\t\t{\n\t\t\tBN_ULONG u0,u1,b0,b1,mask;\n\t\t\tu0   = udp[0];\n\t\t\tb0   = bdp[0];\n\t\t\tmask = (BN_ULONG)0-(b0&1);\n\t\t\tb0  ^= p->d[0]&mask;\n\t\t\tfor (i=0;i<top-1;i++)\n\t\t\t\t{\n\t\t\t\tu1 = udp[i+1];\n\t\t\t\tudp[i] = ((u0>>1)|(u1<<(BN_BITS2-1)))&BN_MASK2;\n\t\t\t\tu0 = u1;\n\t\t\t\tb1 = bdp[i+1]^(p->d[i+1]&mask);\n\t\t\t\tbdp[i] = ((b0>>1)|(b1<<(BN_BITS2-1)))&BN_MASK2;\n\t\t\t\tb0 = b1;\n\t\t\t\t}\n\t\t\tudp[i] = u0>>1;\n\t\t\tbdp[i] = b0>>1;\n\t\t\tubits--;\n\t\t\t}\n\t\tif (ubits<=BN_BITS2 && udp[0]==1) break;\n\t\tif (ubits<vbits)\n\t\t\t{\n\t\t\ti = ubits; ubits = vbits; vbits = i;\n\t\t\ttmp = u; u = v; v = tmp;\n\t\t\ttmp = b; b = c; c = tmp;\n\t\t\tudp = vdp; vdp = v->d;\n\t\t\tbdp = cdp; cdp = c->d;\n\t\t\t}\n\t\tfor(i=0;i<top;i++)\n\t\t\t{\n\t\t\tudp[i] ^= vdp[i];\n\t\t\tbdp[i] ^= cdp[i];\n\t\t\t}\n\t\tif (ubits==vbits)\n\t\t\t{\n\t\t\tbn_correct_top(u);\n\t\t\tubits = BN_num_bits(u);\n\t\t\t}\n\t\t}\n\tbn_correct_top(b);\n\t}\n#endif\n\tif (!BN_copy(r, b)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\n#ifdef BN_DEBUG\n        bn_correct_top(c);\n        bn_correct_top(u);\n        bn_correct_top(v);\n#endif\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\tBN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tint ret = 0;\n\tconst int max = BN_num_bits(p) + 1;\n\tint *arr=NULL;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(p);\n\tif ((arr = (int *)OPENSSL_malloc(sizeof(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_MUL,BN_R_INVALID_LENGTH);\n\t\tgoto err;\n\t\t}\n\tret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);\n\tbn_check_top(r);\nerr:\n\tif (arr) OPENSSL_free(arr);\n\treturn ret;\n\t}', 'int\tBN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx)\n\t{\n\tint zlen, i, j, k, ret = 0;\n\tBIGNUM *s;\n\tBN_ULONG x1, x0, y1, y0, zz[4];\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tif (a == b)\n\t\t{\n\t\treturn BN_GF2m_mod_sqr_arr(r, a, p, ctx);\n\t\t}\n\tBN_CTX_start(ctx);\n\tif ((s = BN_CTX_get(ctx)) == NULL) goto err;\n\tzlen = a->top + b->top + 4;\n\tif (!bn_wexpand(s, zlen)) goto err;\n\ts->top = zlen;\n\tfor (i = 0; i < zlen; i++) s->d[i] = 0;\n\tfor (j = 0; j < b->top; j += 2)\n\t\t{\n\t\ty0 = b->d[j];\n\t\ty1 = ((j+1) == b->top) ? 0 : b->d[j+1];\n\t\tfor (i = 0; i < a->top; i += 2)\n\t\t\t{\n\t\t\tx0 = a->d[i];\n\t\t\tx1 = ((i+1) == a->top) ? 0 : a->d[i+1];\n\t\t\tbn_GF2m_mul_2x2(zz, x1, x0, y1, y0);\n\t\t\tfor (k = 0; k < 4; k++) s->d[i+j+k] ^= zz[k];\n\t\t\t}\n\t\t}\n\tbn_correct_top(s);\n\tif (BN_GF2m_mod_arr(r, s, p))\n\t\tret = 1;\n\tbn_check_top(r);\nerr:\n\tBN_CTX_end(ctx);\n\treturn ret;\n\t}', 'int\tBN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const 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}', '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}', '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}']