crypto/dsa/dsa_ossl.c:142: error: BUFFER_OVERRUN_L3
  Offset: [16, +oo] Size: [0, +oo] by call to `BN_mod_mul`.
Showing all 11 steps of the trace


crypto/dsa/dsa_ossl.c:141:3: Call
139.   	if (!BN_add(s, &xr, &m)) goto err;		/* s = m + xr */
140.   	if (BN_cmp(s,dsa->q) > 0)
141.   		BN_sub(s,s,dsa->q);
         ^
142.   	if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err;
143.   

crypto/bn/bn_add.c:258:1: Parameter `a->top`
  256.   	}
  257.   
  258. > int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
  259.   	{
  260.   	int max;

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

crypto/bn/bn_exp.c:66:1: Parameter `*a->d`
  64.   
  65.   /* slow but works */
  66. > int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
  67.   	{
  68.   	BIGNUM *t;

crypto/bn/bn_exp.c:79:10: Call
  77.   		{ if (!BN_sqr(t,a,ctx)) goto err; }
  78.   	else
  79.   		{ if (!BN_mul(t,a,b,ctx)) goto err; }
                 ^
  80.   	if (!BN_mod(ret,t,m,ctx)) goto err;
  81.   	r=1;

crypto/bn/bn_mul.c:560:1: <Offset trace>
558.   #endif
559.   
560. > int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
561.   	{
562.   	int top,al,bl;

crypto/bn/bn_mul.c:560:1: Parameter `a->top`
    558.   #endif
    559.   
    560. > int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
    561.   	{
    562.   	int top,al,bl;

crypto/bn/bn_mul.c:577:2: Assignment
    575.   	bn_check_top(r);
    576.   
    577.   	al=a->top;
            ^
    578.   	bl=b->top;
    579.   	r->neg=a->neg^b->neg;

crypto/bn/bn_mul.c:560:1: <Length trace>
558.   #endif
559.   
560. > int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
561.   	{
562.   	int top,al,bl;

crypto/bn/bn_mul.c:560:1: Parameter `*a->d`
    558.   #endif
    559.   
    560. > int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
    561.   	{
    562.   	int top,al,bl;

crypto/bn/bn_mul.c:648:4: Array access: Offset: [16, +oo] Size: [0, +oo] by call to `BN_mod_mul` 
    646.   			{
    647.   			bn_wexpand(a,bl);
    648.   			a->d[al]=0;
              ^
    649.   			al++;
    650.   			goto symetric;

int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
	{
	int top,al,bl;
	BIGNUM *rr;
#ifdef BN_RECURSION
	BIGNUM *t;
	int i,j,k;
#endif
#ifdef BN_COUNT
printf("BN_mul %d * %d\n",a->top,b->top);
#endif
	bn_check_top(a);
	bn_check_top(b);
	bn_check_top(r);
	al=a->top;
	bl=b->top;
	r->neg=a->neg^b->neg;
	if ((al == 0) || (bl == 0))
		{
		BN_zero(r);
		return(1);
		}
	top=al+bl;
	if ((r == a) || (r == b))
		rr= &(ctx->bn[ctx->tos+1]);
	else
		rr=r;
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
	if (al == bl)
		{
#  ifdef BN_MUL_COMBA
  if (al == 8)
			{
			if (bn_wexpand(rr,16) == NULL) return(0);
			rr->top=16;
			bn_mul_comba8(rr->d,a->d,b->d);
			goto end;
			}
		else
#  endif
#ifdef BN_RECURSION
		if (al < BN_MULL_SIZE_NORMAL)
#endif
			{
			if (bn_wexpand(rr,top) == NULL) return(0);
			rr->top=top;
			bn_mul_normal(rr->d,a->d,al,b->d,bl);
			goto end;
			}
#  ifdef BN_RECURSION
		goto symetric;
#  endif
		}
#endif
#ifdef BN_RECURSION
	else if ((al < BN_MULL_SIZE_NORMAL) || (bl < BN_MULL_SIZE_NORMAL))
		{
		if (bn_wexpand(rr,top) == NULL) return(0);
		rr->top=top;
		bn_mul_normal(rr->d,a->d,al,b->d,bl);
		goto end;
		}
	else
		{
		i=(al-bl);
		if ((i ==  1) && !BN_get_flags(b,BN_FLG_STATIC_DATA))
			{
			bn_wexpand(b,al);
			b->d[bl]=0;
			bl++;
			goto symetric;
			}
		else if ((i ==  -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA))
			{
			bn_wexpand(a,bl);
			a->d[al]=0;
			al++;
			goto symetric;
			}
		}
#endif
	if (bn_wexpand(rr,top) == NULL) return(0);
	rr->top=top;
	bn_mul_normal(rr->d,a->d,al,b->d,bl);
#ifdef BN_RECURSION
	if (0)
		{
symetric:
		j=BN_num_bits_word((BN_ULONG)al);
		j=1<<(j-1);
		k=j+j;
		t= &(ctx->bn[ctx->tos]);
		if (al == j)
			{
			bn_wexpand(t,k*2);
			bn_wexpand(rr,k*2);
			bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
			}
		else
			{
			bn_wexpand(a,k);
			bn_wexpand(b,k);
			bn_wexpand(t,k*4);
			bn_wexpand(rr,k*4);
			for (i=a->top; i<k; i++)
				a->d[i]=0;
			for (i=b->top; i<k; i++)
				b->d[i]=0;
			bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
			}
		rr->top=top;
		}
#endif
#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
end:
#endif
	bn_fix_top(rr);
	if (r != rr) BN_copy(r,rr);
	return(1);
	}
['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}', 'int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n\t{\n\tint max;\n\tint add=0,neg=0;\n\tconst BIGNUM *tmp;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tif (a->neg)\n\t\t{\n\t\tif (b->neg)\n\t\t\t{ tmp=a; a=b; b=tmp; }\n\t\telse\n\t\t\t{ add=1; neg=1; }\n\t\t}\n\telse\n\t\t{\n\t\tif (b->neg) { add=1; neg=0; }\n\t\t}\n\tif (add)\n\t\t{\n\t\tif (!BN_uadd(r,a,b)) return(0);\n\t\tr->neg=neg;\n\t\treturn(1);\n\t\t}\n\tmax=(a->top > b->top)?a->top:b->top;\n\tif (bn_wexpand(r,max) == NULL) return(0);\n\tif (BN_ucmp(a,b) < 0)\n\t\t{\n\t\tif (!BN_usub(r,b,a)) return(0);\n\t\tr->neg=1;\n\t\t}\n\telse\n\t\t{\n\t\tif (!BN_usub(r,a,b)) return(0);\n\t\tr->neg=0;\n\t\t}\n\treturn(1);\n\t}', 'int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_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\tt= &(ctx->bn[ctx->tos++]);\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\tctx->tos--;\n\treturn(r);\n\t}', 'int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)\n\t{\n\tint top,al,bl;\n\tBIGNUM *rr;\n#ifdef BN_RECURSION\n\tBIGNUM *t;\n\tint i,j,k;\n#endif\n#ifdef BN_COUNT\nprintf("BN_mul %d * %d\\n",a->top,b->top);\n#endif\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(r);\n\tal=a->top;\n\tbl=b->top;\n\tr->neg=a->neg^b->neg;\n\tif ((al == 0) || (bl == 0))\n\t\t{\n\t\tBN_zero(r);\n\t\treturn(1);\n\t\t}\n\ttop=al+bl;\n\tif ((r == a) || (r == b))\n\t\trr= &(ctx->bn[ctx->tos+1]);\n\telse\n\t\trr=r;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n\tif (al == bl)\n\t\t{\n#  ifdef BN_MUL_COMBA\n  if (al == 8)\n\t\t\t{\n\t\t\tif (bn_wexpand(rr,16) == NULL) return(0);\n\t\t\trr->top=16;\n\t\t\tbn_mul_comba8(rr->d,a->d,b->d);\n\t\t\tgoto end;\n\t\t\t}\n\t\telse\n#  endif\n#ifdef BN_RECURSION\n\t\tif (al < BN_MULL_SIZE_NORMAL)\n#endif\n\t\t\t{\n\t\t\tif (bn_wexpand(rr,top) == NULL) return(0);\n\t\t\trr->top=top;\n\t\t\tbn_mul_normal(rr->d,a->d,al,b->d,bl);\n\t\t\tgoto end;\n\t\t\t}\n#  ifdef BN_RECURSION\n\t\tgoto symetric;\n#  endif\n\t\t}\n#endif\n#ifdef BN_RECURSION\n\telse if ((al < BN_MULL_SIZE_NORMAL) || (bl < BN_MULL_SIZE_NORMAL))\n\t\t{\n\t\tif (bn_wexpand(rr,top) == NULL) return(0);\n\t\trr->top=top;\n\t\tbn_mul_normal(rr->d,a->d,al,b->d,bl);\n\t\tgoto end;\n\t\t}\n\telse\n\t\t{\n\t\ti=(al-bl);\n\t\tif ((i ==  1) && !BN_get_flags(b,BN_FLG_STATIC_DATA))\n\t\t\t{\n\t\t\tbn_wexpand(b,al);\n\t\t\tb->d[bl]=0;\n\t\t\tbl++;\n\t\t\tgoto symetric;\n\t\t\t}\n\t\telse if ((i ==  -1) && !BN_get_flags(a,BN_FLG_STATIC_DATA))\n\t\t\t{\n\t\t\tbn_wexpand(a,bl);\n\t\t\ta->d[al]=0;\n\t\t\tal++;\n\t\t\tgoto symetric;\n\t\t\t}\n\t\t}\n#endif\n\tif (bn_wexpand(rr,top) == NULL) return(0);\n\trr->top=top;\n\tbn_mul_normal(rr->d,a->d,al,b->d,bl);\n#ifdef BN_RECURSION\n\tif (0)\n\t\t{\nsymetric:\n\t\tj=BN_num_bits_word((BN_ULONG)al);\n\t\tj=1<<(j-1);\n\t\tk=j+j;\n\t\tt= &(ctx->bn[ctx->tos]);\n\t\tif (al == j)\n\t\t\t{\n\t\t\tbn_wexpand(t,k*2);\n\t\t\tbn_wexpand(rr,k*2);\n\t\t\tbn_mul_recursive(rr->d,a->d,b->d,al,t->d);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tbn_wexpand(a,k);\n\t\t\tbn_wexpand(b,k);\n\t\t\tbn_wexpand(t,k*4);\n\t\t\tbn_wexpand(rr,k*4);\n\t\t\tfor (i=a->top; i<k; i++)\n\t\t\t\ta->d[i]=0;\n\t\t\tfor (i=b->top; i<k; i++)\n\t\t\t\tb->d[i]=0;\n\t\t\tbn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);\n\t\t\t}\n\t\trr->top=top;\n\t\t}\n#endif\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\nend:\n#endif\n\tbn_fix_top(rr);\n\tif (r != rr) BN_copy(r,rr);\n\treturn(1);\n\t}']