crypto/dsa/dsa_ossl.c:143: error: BUFFER_OVERRUN_L3
  Offset: [-1, 5] Size: 12 by call to `BN_mod_mul`.
Showing all 26 steps of the trace


crypto/dsa/dsa_ossl.c:121:6: Call
119.   		}
120.   
121.   	ctx=BN_CTX_new();
            ^
122.   	if (ctx == NULL) goto err;
123.   

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:139:7: Call
137.   
138.   	/* Compute  s = inv(k) (m + xr) mod q */
139.   	if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */
             ^
140.   	if (!BN_add(s, &xr, &m)) goto err;		/* s = m + xr */
141.   	if (BN_cmp(s,dsa->q) > 0)

crypto/bn/bn_exp.c:120:1: Parameter `ctx->depth`
  118.   
  119.   /* slow but works */
  120. > int BN_mod_mul(BIGNUM *ret, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  121.   	BN_CTX *ctx)
  122.   	{

crypto/bn/bn_exp.c:130:2: Call
  128.   	bn_check_top(m);
  129.   
  130.   	BN_CTX_start(ctx);
          ^
  131.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
  132.   	if (a == b)

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_exp.c:131:11: Call
  129.   
  130.   	BN_CTX_start(ctx);
  131.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
                   ^
  132.   	if (a == b)
  133.   		{ if (!BN_sqr(t,a,ctx)) 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_exp.c:139:2: Call
  137.   	r=1;
  138.   err:
  139.   	BN_CTX_end(ctx);
          ^
  140.   	return(r);
  141.   	}

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/dsa/dsa_ossl.c:143:7: Call
141.   	if (BN_cmp(s,dsa->q) > 0)
142.   		BN_sub(s,s,dsa->q);
143.   	if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
             ^
144.   
145.   	ret=DSA_SIG_new();

crypto/bn/bn_exp.c:120:1: Parameter `ctx->depth`
  118.   
  119.   /* slow but works */
  120. > int BN_mod_mul(BIGNUM *ret, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  121.   	BN_CTX *ctx)
  122.   	{

crypto/bn/bn_exp.c:130:2: Call
  128.   	bn_check_top(m);
  129.   
  130.   	BN_CTX_start(ctx);
          ^
  131.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
  132.   	if (a == b)

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_exp.c:131:11: Call
  129.   
  130.   	BN_CTX_start(ctx);
  131.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
                   ^
  132.   	if (a == b)
  133.   		{ if (!BN_sqr(t,a,ctx)) 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_exp.c:139:2: Call
  137.   	r=1;
  138.   err:
  139.   	BN_CTX_end(ctx);
          ^
  140.   	return(r);
  141.   	}

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, 5] Size: 12 by call to `BN_mod_mul` 
    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 DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)\n\t{\n\tBIGNUM *kinv=NULL,*r=NULL,*s=NULL;\n\tBIGNUM m;\n\tBIGNUM xr;\n\tBN_CTX *ctx=NULL;\n\tint i,reason=ERR_R_BN_LIB;\n\tDSA_SIG *ret=NULL;\n\tBN_init(&m);\n\tBN_init(&xr);\n\ts=BN_new();\n\tif (s == NULL) goto err;\n\ti=BN_num_bytes(dsa->q);\n\tif ((dlen > i) || (dlen > 50))\n\t\t{\n\t\treason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;\n\t\tgoto err;\n\t\t}\n\tctx=BN_CTX_new();\n\tif (ctx == NULL) goto err;\n\tif ((dsa->kinv == NULL) || (dsa->r == NULL))\n\t\t{\n\t\tif (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err;\n\t\t}\n\telse\n\t\t{\n\t\tkinv=dsa->kinv;\n\t\tdsa->kinv=NULL;\n\t\tr=dsa->r;\n\t\tdsa->r=NULL;\n\t\t}\n\tif (BN_bin2bn(dgst,dlen,&m) == NULL) goto err;\n\tif (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;\n\tif (!BN_add(s, &xr, &m)) goto err;\n\tif (BN_cmp(s,dsa->q) > 0)\n\t\tBN_sub(s,s,dsa->q);\n\tif (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;\n\tret=DSA_SIG_new();\n\tif (ret == NULL) goto err;\n\tret->r = r;\n\tret->s = s;\nerr:\n\tif (!ret)\n\t\t{\n\t\tDSAerr(DSA_F_DSA_DO_SIGN,reason);\n\t\tBN_free(r);\n\t\tBN_free(s);\n\t\t}\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tBN_clear_free(&m);\n\tBN_clear_free(&xr);\n\tif (kinv != NULL)\n\t    BN_clear_free(kinv);\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}', 'int BN_mod_mul(BIGNUM *ret, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n\tBN_CTX *ctx)\n\t{\n\tBIGNUM *t;\n\tint r=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_mod(ret,t,m,ctx)) goto err;\n\tr=1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn(r);\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}']