crypto/ec/ec_mult.c:883: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_CTX_end`.
Showing all 7 steps of the trace


crypto/ec/ec_mult.c:735:1: Parameter `ctx->pool.used`
733.    * points[2^(w-1)*numblocks]       = NULL
734.    */
735. > int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
736.   	{
737.   	const EC_POINT *generator;

crypto/ec/ec_mult.c:883:3: Call
881.    err:
882.   	if (ctx != NULL)
883.   		BN_CTX_end(ctx);
         ^
884.   	if (new_ctx != NULL)
885.   		BN_CTX_free(new_ctx);

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

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

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

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

crypto/bn/bn_ctx.c:440:2: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_CTX_end` 
    438.   static void BN_POOL_release(BN_POOL *p, unsigned int num)
    439.   	{
    440.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
            ^
    441.   	p->used -= num;
    442.   	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 ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)\n\t{\n\tconst EC_POINT *generator;\n\tEC_POINT *tmp_point = NULL, *base = NULL, **var;\n\tBN_CTX *new_ctx = NULL;\n\tBIGNUM *order;\n\tsize_t i, bits, w, pre_points_per_block, blocksize, numblocks, num;\n\tEC_POINT **points = NULL;\n\tEC_PRE_COMP *pre_comp;\n\tint ret = 0;\n\tEC_EX_DATA_free_data(&group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free);\n\tif ((pre_comp = ec_pre_comp_new(group)) == NULL)\n\t\treturn 0;\n\tgenerator = EC_GROUP_get0_generator(group);\n\tif (generator == NULL)\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNDEFINED_GENERATOR);\n\t\tgoto err;\n\t\t}\n\tif (ctx == NULL)\n\t\t{\n\t\tctx = new_ctx = BN_CTX_new();\n\t\tif (ctx == NULL)\n\t\t\tgoto err;\n\t\t}\n\tBN_CTX_start(ctx);\n\torder = BN_CTX_get(ctx);\n\tif (order == NULL) goto err;\n\tif (!EC_GROUP_get_order(group, order, ctx)) goto err;\n\tif (BN_is_zero(order))\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNKNOWN_ORDER);\n\t\tgoto err;\n\t\t}\n\tbits = BN_num_bits(order);\n\tblocksize = 8;\n\tw = 4;\n\tif (EC_window_bits_for_scalar_size(bits) > w)\n\t\t{\n\t\tw = EC_window_bits_for_scalar_size(bits);\n\t\t}\n\tnumblocks = (bits + blocksize - 1) / blocksize;\n\tpre_points_per_block = 1u << (w - 1);\n\tnum = pre_points_per_block * numblocks;\n\tpoints = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1));\n\tif (!points)\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tvar = points;\n\tvar[num] = NULL;\n\tfor (i = 0; i < num; i++)\n\t\t{\n\t\tif ((var[i] = EC_POINT_new(group)) == NULL)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tif (!(tmp_point = EC_POINT_new(group)) || !(base = EC_POINT_new(group)))\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tif (!EC_POINT_copy(base, generator))\n\t\tgoto err;\n\tfor (i = 0; i < numblocks; i++)\n\t\t{\n\t\tsize_t j;\n\t\tif (!EC_POINT_dbl(group, tmp_point, base, ctx))\n\t\t\tgoto err;\n\t\tif (!EC_POINT_copy(*var++, base))\n\t\t\tgoto err;\n\t\tfor (j = 1; j < pre_points_per_block; j++, var++)\n\t\t\t{\n\t\t\tif (!EC_POINT_add(group, *var, tmp_point, *(var - 1), ctx))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\tif (i < numblocks - 1)\n\t\t\t{\n\t\t\tsize_t k;\n\t\t\tif (blocksize <= 2)\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (!EC_POINT_dbl(group, base, tmp_point, ctx))\n\t\t\t\tgoto err;\n\t\t\tfor (k = 2; k < blocksize; k++)\n\t\t\t\t{\n\t\t\t\tif (!EC_POINT_dbl(group,base,base,ctx))\n\t\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n \t\t}\n\tif (!EC_POINTs_make_affine(group, num, points, ctx))\n\t\tgoto err;\n\tpre_comp->group = group;\n\tpre_comp->blocksize = blocksize;\n\tpre_comp->numblocks = numblocks;\n\tpre_comp->w = w;\n\tpre_comp->points = points;\n\tpoints = NULL;\n\tpre_comp->num = num;\n\tif (!EC_EX_DATA_set_data(&group->extra_data, pre_comp,\n\t\tec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free))\n\t\tgoto err;\n\tpre_comp = NULL;\n\tret = 1;\n err:\n\tif (ctx != NULL)\n\t\tBN_CTX_end(ctx);\n\tif (new_ctx != NULL)\n\t\tBN_CTX_free(new_ctx);\n\tif (pre_comp)\n\t\tec_pre_comp_free(pre_comp);\n\tif (points)\n\t\t{\n\t\tEC_POINT **p;\n\t\tfor (p = points; *p != NULL; p++)\n\t\t\tEC_POINT_free(*p);\n\t\tOPENSSL_free(points);\n\t\t}\n\tif (tmp_point)\n\t\tEC_POINT_free(tmp_point);\n\tif (base)\n\t\tEC_POINT_free(base);\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}', '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}']