crypto/dh/dh_key.c:188: error: BUFFER_OVERRUN_L3
  Offset: [-2, +oo] Size: 12 by call to `BN_CTX_end`.
Showing all 14 steps of the trace


crypto/dh/dh_key.c:163:2: Call
161.   	int ret= -1;
162.   
163.   	BN_CTX_init(&ctx);
        ^
164.   	BN_CTX_start(&ctx);
165.   	tmp = BN_CTX_get(&ctx);

crypto/bn/bn_ctx.c:89:2: Assignment
  87.   	ctx->tos = 0;
  88.   	ctx->flags = 0;
  89.   	ctx->depth = 0;
         ^
  90.   	ctx->too_many = 0;
  91.   	for (i = 0; i < BN_CTX_NUM; i++)

crypto/dh/dh_key.c:164:2: Call
162.   
163.   	BN_CTX_init(&ctx);
164.   	BN_CTX_start(&ctx);
        ^
165.   	tmp = BN_CTX_get(&ctx);
166.   	

crypto/bn/bn_ctx.c:108:1: Parameter `ctx->depth`
  106.   	}
  107.   
  108. > void BN_CTX_start(BN_CTX *ctx)
  109.   	{
  110.   	if (ctx->depth < BN_CTX_NUM_POS)

crypto/bn/bn_ctx.c:112:2: Assignment
  110.   	if (ctx->depth < BN_CTX_NUM_POS)
  111.   		ctx->pos[ctx->depth] = ctx->tos;
  112.   	ctx->depth++;
          ^
  113.   	}
  114.   

crypto/dh/dh_key.c:165:8: Call
163.   	BN_CTX_init(&ctx);
164.   	BN_CTX_start(&ctx);
165.   	tmp = BN_CTX_get(&ctx);
              ^
166.   	
167.   	if (dh->priv_key == NULL)

crypto/bn/bn_ctx.c:115:1: Parameter `ctx->depth`
  113.   	}
  114.   
  115. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  116.   	{
  117.   	if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)

crypto/dh/dh_key.c:188:2: Call
186.   	ret=BN_bn2bin(tmp,key);
187.   err:
188.   	BN_CTX_end(&ctx);
        ^
189.   	BN_CTX_free(&ctx);
190.   	return(ret);

crypto/bn/bn_ctx.c:130:1: <Offset trace>
128.   	}
129.   
130. > void BN_CTX_end(BN_CTX *ctx)
131.   	{
132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:130:1: Parameter `ctx->depth`
  128.   	}
  129.   
  130. > void BN_CTX_end(BN_CTX *ctx)
  131.   	{
  132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:141:2: Assignment
  139.   
  140.   	ctx->too_many = 0;
  141.   	ctx->depth--;
          ^
  142.   	if (ctx->depth < BN_CTX_NUM_POS)
  143.   		ctx->tos = ctx->pos[ctx->depth];

crypto/bn/bn_ctx.c:130:1: <Length trace>
128.   	}
129.   
130. > void BN_CTX_end(BN_CTX *ctx)
131.   	{
132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:130:1: Parameter `ctx->pos[*]`
  128.   	}
  129.   
  130. > void BN_CTX_end(BN_CTX *ctx)
  131.   	{
  132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:143:14: Array access: Offset: [-2, +oo] Size: 12 by call to `BN_CTX_end` 
  141.   	ctx->depth--;
  142.   	if (ctx->depth < BN_CTX_NUM_POS)
  143.   		ctx->tos = ctx->pos[ctx->depth];
                      ^
  144.   	}

void BN_CTX_end(BN_CTX *ctx)
	{
	if (ctx == NULL) return;
	assert(ctx->depth > 0);
	if (ctx->depth == 0)
		BN_CTX_start(ctx);
	ctx->too_many = 0;
	ctx->depth--;
	if (ctx->depth < BN_CTX_NUM_POS)
		ctx->tos = ctx->pos[ctx->depth];
	}
['static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)\n\t{\n\tBN_CTX ctx;\n\tBN_MONT_CTX *mont;\n\tBIGNUM *tmp;\n\tint ret= -1;\n\tBN_CTX_init(&ctx);\n\tBN_CTX_start(&ctx);\n\ttmp = BN_CTX_get(&ctx);\n\tif (dh->priv_key == NULL)\n\t\t{\n\t\tDHerr(DH_F_DH_COMPUTE_KEY,DH_R_NO_PRIVATE_VALUE);\n\t\tgoto err;\n\t\t}\n\tif ((dh->method_mont_p == NULL) && (dh->flags & DH_FLAG_CACHE_MONT_P))\n\t\t{\n\t\tif ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)\n\t\t\tif (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,\n\t\t\t\tdh->p,&ctx)) goto err;\n\t\t}\n\tmont=(BN_MONT_CTX *)dh->method_mont_p;\n\tif (!dh->meth->bn_mod_exp(dh, tmp,pub_key,dh->priv_key,dh->p,&ctx,mont))\n\t\t{\n\t\tDHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB);\n\t\tgoto err;\n\t\t}\n\tret=BN_bn2bin(tmp,key);\nerr:\n\tBN_CTX_end(&ctx);\n\tBN_CTX_free(&ctx);\n\treturn(ret);\n\t}', 'void BN_CTX_init(BN_CTX *ctx)\n\t{\n\tint i;\n\tctx->tos = 0;\n\tctx->flags = 0;\n\tctx->depth = 0;\n\tctx->too_many = 0;\n\tfor (i = 0; i < BN_CTX_NUM; i++)\n\t\tBN_init(&(ctx->bn[i]));\n\t}', 'void BN_CTX_start(BN_CTX *ctx)\n\t{\n\tif (ctx->depth < BN_CTX_NUM_POS)\n\t\tctx->pos[ctx->depth] = ctx->tos;\n\tctx->depth++;\n\t}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n\t{\n\tif (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)\n\t\t{\n\t\tif (!ctx->too_many)\n\t\t\t{\n\t\t\tBNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\t\tctx->too_many = 1;\n\t\t\t}\n\t\treturn NULL;\n\t\t}\n\treturn (&(ctx->bn[ctx->tos++]));\n\t}', 'void BN_CTX_end(BN_CTX *ctx)\n\t{\n\tif (ctx == NULL) return;\n\tassert(ctx->depth > 0);\n\tif (ctx->depth == 0)\n\t\tBN_CTX_start(ctx);\n\tctx->too_many = 0;\n\tctx->depth--;\n\tif (ctx->depth < BN_CTX_NUM_POS)\n\t\tctx->tos = ctx->pos[ctx->depth];\n\t}']