crypto/dsa/dsa_ossl.c:240: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: 12 by call to `BN_mod_inverse`.
Showing all 27 steps of the trace


crypto/dsa/dsa_ossl.c:233:11: Call
231.   	int ret = -1;
232.   
233.   	if ((ctx=BN_CTX_new()) == NULL) goto err;
                 ^
234.   	BN_init(&u1);
235.   	BN_init(&u2);

crypto/bn/bn_ctx.c:79:2: Call
  77.   		}
  78.   
  79.   	BN_CTX_init(ret);
         ^
  80.   	ret->flags=BN_FLG_MALLOCED;
  81.   	return(ret);

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/dsa/dsa_ossl.c:240:7: Call
238.   	/* Calculate W = inv(S) mod Q
239.   	 * save W in u2 */
240.   	if ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;
             ^
241.   
242.   	/* save M in u1 */

crypto/bn/bn_gcd.c:147:1: Parameter `ctx->depth`
  145.   
  146.   /* solves ax == 1 (mod n) */
  147. > BIGNUM *BN_mod_inverse(BIGNUM *in,
  148.   	const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
  149.   	{

crypto/bn/bn_gcd.c:157:2: Call
  155.   	bn_check_top(n);
  156.   
  157.   	BN_CTX_start(ctx);
          ^
  158.   	A = BN_CTX_get(ctx);
  159.   	B = BN_CTX_get(ctx);

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/bn/bn_gcd.c:158:6: Call
  156.   
  157.   	BN_CTX_start(ctx);
  158.   	A = BN_CTX_get(ctx);
              ^
  159.   	B = BN_CTX_get(ctx);
  160.   	X = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:116:1: Parameter `ctx->depth`
    114.   
    115.   
    116. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    117.   	{
    118.   	/* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,

crypto/bn/bn_gcd.c:159:6: Call
  157.   	BN_CTX_start(ctx);
  158.   	A = BN_CTX_get(ctx);
  159.   	B = BN_CTX_get(ctx);
              ^
  160.   	X = BN_CTX_get(ctx);
  161.   	D = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:116:1: Parameter `ctx->depth`
    114.   
    115.   
    116. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    117.   	{
    118.   	/* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,

crypto/bn/bn_gcd.c:160:6: Call
  158.   	A = BN_CTX_get(ctx);
  159.   	B = BN_CTX_get(ctx);
  160.   	X = BN_CTX_get(ctx);
              ^
  161.   	D = BN_CTX_get(ctx);
  162.   	M = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:116:1: Parameter `ctx->depth`
    114.   
    115.   
    116. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    117.   	{
    118.   	/* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,

crypto/bn/bn_gcd.c:161:6: Call
  159.   	B = BN_CTX_get(ctx);
  160.   	X = BN_CTX_get(ctx);
  161.   	D = BN_CTX_get(ctx);
              ^
  162.   	M = BN_CTX_get(ctx);
  163.   	Y = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:116:1: Parameter `ctx->depth`
    114.   
    115.   
    116. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    117.   	{
    118.   	/* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,

crypto/bn/bn_gcd.c:162:6: Call
  160.   	X = BN_CTX_get(ctx);
  161.   	D = BN_CTX_get(ctx);
  162.   	M = BN_CTX_get(ctx);
              ^
  163.   	Y = BN_CTX_get(ctx);
  164.   	if (Y == NULL) goto err;

crypto/bn/bn_ctx.c:116:1: Parameter `ctx->depth`
    114.   
    115.   
    116. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    117.   	{
    118.   	/* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,

crypto/bn/bn_gcd.c:163:6: Call
  161.   	D = BN_CTX_get(ctx);
  162.   	M = BN_CTX_get(ctx);
  163.   	Y = BN_CTX_get(ctx);
              ^
  164.   	if (Y == NULL) goto err;
  165.   

crypto/bn/bn_ctx.c:116:1: Parameter `ctx->depth`
    114.   
    115.   
    116. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    117.   	{
    118.   	/* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,

crypto/bn/bn_gcd.c:208:2: Call
  206.   err:
  207.   	if ((ret == NULL) && (in == NULL)) BN_free(R);
  208.   	BN_CTX_end(ctx);
          ^
  209.   	return(ret);
  210.   	}

crypto/bn/bn_ctx.c:136:1: <Offset trace>
134.   	}
135.   
136. > void BN_CTX_end(BN_CTX *ctx)
137.   	{
138.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:136:1: Parameter `ctx->depth`
    134.   	}
    135.   
    136. > void BN_CTX_end(BN_CTX *ctx)
    137.   	{
    138.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:147:2: Assignment
    145.   
    146.   	ctx->too_many = 0;
    147.   	ctx->depth--;
            ^
    148.   	if (ctx->depth < BN_CTX_NUM_POS)
    149.   		ctx->tos = ctx->pos[ctx->depth];

crypto/bn/bn_ctx.c:136:1: <Length trace>
134.   	}
135.   
136. > void BN_CTX_end(BN_CTX *ctx)
137.   	{
138.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:136:1: Parameter `ctx->pos[*]`
    134.   	}
    135.   
    136. > void BN_CTX_end(BN_CTX *ctx)
    137.   	{
    138.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:149:14: Array access: Offset: [-1, +oo] Size: 12 by call to `BN_mod_inverse` 
    147.   	ctx->depth--;
    148.   	if (ctx->depth < BN_CTX_NUM_POS)
    149.   		ctx->tos = ctx->pos[ctx->depth];
                        ^
    150.   	}

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 dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,\n\t\t  DSA *dsa)\n\t{\n\tBN_CTX *ctx;\n\tBIGNUM u1,u2,t1;\n\tBN_MONT_CTX *mont=NULL;\n\tint ret = -1;\n\tif ((ctx=BN_CTX_new()) == NULL) goto err;\n\tBN_init(&u1);\n\tBN_init(&u2);\n\tBN_init(&t1);\n\tif ((BN_mod_inverse(&u2,sig->s,dsa->q,ctx)) == NULL) goto err;\n\tif (BN_bin2bn(dgst,dgst_len,&u1) == NULL) goto err;\n\tif (!BN_mod_mul(&u1,&u1,&u2,dsa->q,ctx)) goto err;\n\tif (!BN_mod_mul(&u2,sig->r,&u2,dsa->q,ctx)) goto err;\n\tif ((dsa->method_mont_p == NULL) && (dsa->flags & DSA_FLAG_CACHE_MONT_P))\n\t\t{\n\t\tif ((dsa->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)\n\t\t\tif (!BN_MONT_CTX_set((BN_MONT_CTX *)dsa->method_mont_p,\n\t\t\t\tdsa->p,ctx)) goto err;\n\t\t}\n\tmont=(BN_MONT_CTX *)dsa->method_mont_p;\n#if 0\n\t{\n\tBIGNUM t2;\n\tBN_init(&t2);\n\tif (!BN_mod_exp_mont(&t1,dsa->g,&u1,dsa->p,ctx,mont)) goto err;\n\tif (!BN_mod_exp_mont(&t2,dsa->pub_key,&u2,dsa->p,ctx,mont)) goto err;\n\tif (!BN_mod_mul(&u1,&t1,&t2,dsa->p,ctx)) goto err_bn;\n\tBN_free(&t2);\n\t}\n\tif (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err;\n#else\n\t{\n\tif (!ENGINE_get_DSA(dsa->engine)->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2,\n\t\t\t\t\t\tdsa->p,ctx,mont)) goto err;\n\tif (!BN_mod(&u1,&t1,dsa->q,ctx)) goto err;\n\t}\n#endif\n\tret=(BN_ucmp(&u1, sig->r) == 0);\n\terr:\n\tif (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY,ERR_R_BN_LIB);\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tBN_free(&u1);\n\tBN_free(&u2);\n\tBN_free(&t1);\n\treturn(ret);\n\t}', 'BN_CTX *BN_CTX_new(void)\n\t{\n\tBN_CTX *ret;\n\tret=(BN_CTX *)OPENSSL_malloc(sizeof(BN_CTX));\n\tif (ret == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tBN_CTX_init(ret);\n\tret->flags=BN_FLG_MALLOCED;\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}', 'BIGNUM *BN_mod_inverse(BIGNUM *in,\n\tconst BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)\n\t{\n\tBIGNUM *A,*B,*X,*Y,*M,*D,*R=NULL;\n\tBIGNUM *T,*ret=NULL;\n\tint sign;\n\tbn_check_top(a);\n\tbn_check_top(n);\n\tBN_CTX_start(ctx);\n\tA = BN_CTX_get(ctx);\n\tB = BN_CTX_get(ctx);\n\tX = BN_CTX_get(ctx);\n\tD = BN_CTX_get(ctx);\n\tM = BN_CTX_get(ctx);\n\tY = BN_CTX_get(ctx);\n\tif (Y == NULL) goto err;\n\tif (in == NULL)\n\t\tR=BN_new();\n\telse\n\t\tR=in;\n\tif (R == NULL) goto err;\n\tBN_zero(X);\n\tBN_one(Y);\n\tif (BN_copy(A,a) == NULL) goto err;\n\tif (BN_copy(B,n) == NULL) goto err;\n\tsign=1;\n\twhile (!BN_is_zero(B))\n\t\t{\n\t\tif (!BN_div(D,M,A,B,ctx)) goto err;\n\t\tT=A;\n\t\tA=B;\n\t\tB=M;\n\t\tif (!BN_mul(T,D,X,ctx)) goto err;\n\t\tif (!BN_add(T,T,Y)) goto err;\n\t\tM=Y;\n\t\tY=X;\n\t\tX=T;\n\t\tsign= -sign;\n\t\t}\n\tif (sign < 0)\n\t\t{\n\t\tif (!BN_sub(Y,n,Y)) goto err;\n\t\t}\n\tif (BN_is_one(A))\n\t\t{ if (!BN_mod(R,Y,n,ctx)) goto err; }\n\telse\n\t\t{\n\t\tBNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);\n\t\tgoto err;\n\t\t}\n\tret=R;\nerr:\n\tif ((ret == NULL) && (in == NULL)) BN_free(R);\n\tBN_CTX_end(ctx);\n\treturn(ret);\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}']