crypto/dh/dh_check.c:110: error: BUFFER_OVERRUN_L3
  Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, +oo] by call to `BN_is_prime`.
Showing all 13 steps of the trace


crypto/dh/dh_check.c:105:7: Call
103.   		*ret|=DH_UNABLE_TO_CHECK_GENERATOR;
104.   
105.   	if (!BN_is_prime(dh->p,BN_prime_checks,NULL,ctx,NULL))
             ^
106.   		*ret|=DH_CHECK_P_NOT_PRIME;
107.   	else

crypto/bn/bn_prime.c:154:1: Parameter `a->top`
  152.   	}
  153.   
  154. > int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *),
  155.   	     BN_CTX *ctx_passed, void *cb_arg)
  156.   	{

crypto/dh/dh_check.c:109:8: Call
107.   	else
108.   		{
109.   		if (!BN_rshift1(q,dh->p)) goto err;
              ^
110.   		if (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL))
111.   			*ret|=DH_CHECK_P_NOT_STRONG_PRIME;

crypto/bn/bn_shift.c:95:1: Parameter `*r->d`
  93.   	}
  94.   
  95. > int BN_rshift1(BIGNUM *r, BIGNUM *a)
  96.   	{
  97.   	BN_ULONG *ap,*rp,t,c;

crypto/dh/dh_check.c:110:8: Call
108.   		{
109.   		if (!BN_rshift1(q,dh->p)) goto err;
110.   		if (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL))
              ^
111.   			*ret|=DH_CHECK_P_NOT_STRONG_PRIME;
112.   		}

crypto/bn/bn_prime.c:154:1: Parameter `*a->d`
  152.   	}
  153.   
  154. > int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *),
  155.   	     BN_CTX *ctx_passed, void *cb_arg)
  156.   	{

crypto/bn/bn_prime.c:175:7: Call
  173.   
  174.   	/* Setup the montgomery structure */
  175.   	if (!BN_MONT_CTX_set(mont,a,ctx2)) goto err;
               ^
  176.   
  177.   	for (i=0; i<checks; i++)

crypto/bn/bn_mont.c:301:1: Parameter `*mod->d`
    299.   	}
    300.   
    301. > int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
    302.   	{
    303.   	BIGNUM Ri,*R;

crypto/bn/bn_mont.c:307:2: Call
    305.   	BN_init(&Ri);
    306.   	R= &(mont->RR);					/* grab RR as a temp */
    307.   	BN_copy(&(mont->N),mod);			/* Set N */
            ^
    308.   
    309.   #ifdef BN_RECURSION_MONT

crypto/bn/bn_lib.c:499:1: <Length trace>
497.   	}
498.   
499. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
500.   	{
501.   	int i;

crypto/bn/bn_lib.c:499:1: Parameter `*b->d`
      497.   	}
      498.   
      499. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
      500.   	{
      501.   	int i;

crypto/bn/bn_lib.c:512:2: Assignment
      510.   #if 1
      511.   	A=a->d;
      512.   	B=b->d;
              ^
      513.   	for (i=b->top>>2; i>0; i--,A+=4,B+=4)
      514.   		{

crypto/bn/bn_lib.c:516:33: Array access: Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, +oo] by call to `BN_is_prime` 
      514.   		{
      515.   		BN_ULONG a0,a1,a2,a3;
      516.   		a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
                                             ^
      517.   		A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
      518.   		}

BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
	{
	int i;
	BN_ULONG *A;
	const BN_ULONG *B;
	bn_check_top(b);
	if (a == b) return(a);
	if (bn_wexpand(a,b->top) == NULL) return(NULL);
#if 1
	A=a->d;
	B=b->d;
	for (i=b->top>>2; i>0; i--,A+=4,B+=4)
		{
		BN_ULONG a0,a1,a2,a3;
		a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
		A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
		}
	switch (b->top&3)
		{
		case 3: A[2]=B[2];
		case 2: A[1]=B[1];
		case 1: A[0]=B[0];
		case 0: ;
		}
#else
	memcpy(a->d,b->d,sizeof(b->d[0])*b->top);
#endif
	a->top=b->top;
	if ((a->top == 0) && (a->d != NULL))
		a->d[0]=0;
	a->neg=b->neg;
	return(a);
	}
['int DH_check(DH *dh, int *ret)\n\t{\n\tint ok=0;\n\tBN_CTX *ctx=NULL;\n\tBN_ULONG l;\n\tBIGNUM *q=NULL;\n\t*ret=0;\n\tctx=BN_CTX_new();\n\tif (ctx == NULL) goto err;\n\tq=BN_new();\n\tif (q == NULL) goto err;\n\tif (BN_is_word(dh->g,DH_GENERATOR_2))\n\t\t{\n\t\tl=BN_mod_word(dh->p,24);\n\t\tif (l != 11) *ret|=DH_NOT_SUITABLE_GENERATOR;\n\t\t}\n\telse if (BN_is_word(dh->g,DH_GENERATOR_5))\n\t\t{\n\t\tl=BN_mod_word(dh->p,10);\n\t\tif ((l != 3) && (l != 7))\n\t\t\t*ret|=DH_NOT_SUITABLE_GENERATOR;\n\t\t}\n\telse\n\t\t*ret|=DH_UNABLE_TO_CHECK_GENERATOR;\n\tif (!BN_is_prime(dh->p,BN_prime_checks,NULL,ctx,NULL))\n\t\t*ret|=DH_CHECK_P_NOT_PRIME;\n\telse\n\t\t{\n\t\tif (!BN_rshift1(q,dh->p)) goto err;\n\t\tif (!BN_is_prime(q,BN_prime_checks,NULL,ctx,NULL))\n\t\t\t*ret|=DH_CHECK_P_NOT_STRONG_PRIME;\n\t\t}\n\tok=1;\nerr:\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tif (q != NULL) BN_free(q);\n\treturn(ok);\n\t}', 'int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *),\n\t     BN_CTX *ctx_passed, void *cb_arg)\n\t{\n\tint i,j,c2=0,ret= -1;\n\tBIGNUM *check;\n\tBN_CTX *ctx=NULL,*ctx2=NULL;\n\tBN_MONT_CTX *mont=NULL;\n\tif (!BN_is_odd(a))\n\t\treturn(0);\n\tif (ctx_passed != NULL)\n\t\tctx=ctx_passed;\n\telse\n\t\tif ((ctx=BN_CTX_new()) == NULL) goto err;\n\tif ((ctx2=BN_CTX_new()) == NULL) goto err;\n\tif ((mont=BN_MONT_CTX_new()) == NULL) goto err;\n\tcheck= &(ctx->bn[ctx->tos++]);\n\tif (!BN_MONT_CTX_set(mont,a,ctx2)) goto err;\n\tfor (i=0; i<checks; i++)\n\t\t{\n\t\tif (!BN_rand(check,BN_num_bits(a)-1,0,0)) goto err;\n\t\tj=witness(check,a,ctx,ctx2,mont);\n\t\tif (j == -1) goto err;\n\t\tif (j)\n\t\t\t{\n\t\t\tret=0;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (callback != NULL) callback(1,c2++,cb_arg);\n\t\t}\n\tret=1;\nerr:\n\tctx->tos--;\n\tif ((ctx_passed == NULL) && (ctx != NULL))\n\t\tBN_CTX_free(ctx);\n\tif (ctx2 != NULL)\n\t\tBN_CTX_free(ctx2);\n\tif (mont != NULL) BN_MONT_CTX_free(mont);\n\treturn(ret);\n\t}', 'int BN_rshift1(BIGNUM *r, BIGNUM *a)\n\t{\n\tBN_ULONG *ap,*rp,t,c;\n\tint i;\n\tif (BN_is_zero(a))\n\t\t{\n\t\tBN_zero(r);\n\t\treturn(1);\n\t\t}\n\tif (a != r)\n\t\t{\n\t\tif (bn_wexpand(r,a->top) == NULL) return(0);\n\t\tr->top=a->top;\n\t\tr->neg=a->neg;\n\t\t}\n\tap=a->d;\n\trp=r->d;\n\tc=0;\n\tfor (i=a->top-1; i>=0; i--)\n\t\t{\n\t\tt=ap[i];\n\t\trp[i]=((t>>1)&BN_MASK2)|c;\n\t\tc=(t&1)?BN_TBIT:0;\n\t\t}\n\tbn_fix_top(r);\n\treturn(1);\n\t}', 'int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)\n\t{\n\tBIGNUM Ri,*R;\n\tBN_init(&Ri);\n\tR= &(mont->RR);\n\tBN_copy(&(mont->N),mod);\n#ifdef BN_RECURSION_MONT\n\tif (mont->N.top < BN_MONT_CTX_SET_SIZE_WORD)\n#endif\n\t\t{\n\t\tBIGNUM tmod;\n\t\tBN_ULONG buf[2];\n\t\tmont->use_word=1;\n\t\tmont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;\n\t\tBN_zero(R);\n\t\tBN_set_bit(R,BN_BITS2);\n\t\tbuf[0]=mod->d[0];\n\t\tbuf[1]=0;\n\t\ttmod.d=buf;\n\t\ttmod.top=1;\n\t\ttmod.max=mod->max;\n\t\ttmod.neg=mod->neg;\n\t\tif ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)\n\t\t\tgoto err;\n\t\tBN_lshift(&Ri,&Ri,BN_BITS2);\n\t\tif (!BN_is_zero(&Ri))\n\t\t\t{\n#if 1\n\t\t\tBN_sub_word(&Ri,1);\n#else\n\t\t\tBN_usub(&Ri,&Ri,BN_value_one());\n#endif\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tBN_set_word(&Ri,BN_MASK2);\n\t\t\t}\n\t\tBN_div(&Ri,NULL,&Ri,&tmod,ctx);\n\t\tmont->n0=Ri.d[0];\n\t\tBN_free(&Ri);\n\t\t}\n#ifdef BN_RECURSION_MONT\n\telse\n\t\t{\n\t\tmont->use_word=0;\n\t\tmont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;\n#if 1\n\t\tBN_zero(R);\n\t\tBN_set_bit(R,mont->ri);\n#else\n\t\tBN_lshift(R,BN_value_one(),mont->ri);\n#endif\n\t\tif ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL)\n\t\t\tgoto err;\n\t\tBN_lshift(&Ri,&Ri,mont->ri);\n#if 1\n\t\tBN_sub_word(&Ri,1);\n#else\n\t\tBN_usub(&Ri,&Ri,BN_value_one());\n#endif\n\t\tBN_div(&(mont->Ni),NULL,&Ri,mod,ctx);\n\t\tBN_free(&Ri);\n\t\t}\n#endif\n#if 1\n\tBN_zero(&(mont->RR));\n\tBN_set_bit(&(mont->RR),mont->ri*2);\n#else\n\tBN_lshift(mont->RR,BN_value_one(),mont->ri*2);\n#endif\n\tBN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx);\n\treturn(1);\nerr:\n\treturn(0);\n\t}', 'BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n\t{\n\tint i;\n\tBN_ULONG *A;\n\tconst BN_ULONG *B;\n\tbn_check_top(b);\n\tif (a == b) return(a);\n\tif (bn_wexpand(a,b->top) == NULL) return(NULL);\n#if 1\n\tA=a->d;\n\tB=b->d;\n\tfor (i=b->top>>2; i>0; i--,A+=4,B+=4)\n\t\t{\n\t\tBN_ULONG a0,a1,a2,a3;\n\t\ta0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];\n\t\tA[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;\n\t\t}\n\tswitch (b->top&3)\n\t\t{\n\t\tcase 3: A[2]=B[2];\n\t\tcase 2: A[1]=B[1];\n\t\tcase 1: A[0]=B[0];\n\t\tcase 0: ;\n\t\t}\n#else\n\tmemcpy(a->d,b->d,sizeof(b->d[0])*b->top);\n#endif\n\ta->top=b->top;\n\tif ((a->top == 0) && (a->d != NULL))\n\t\ta->d[0]=0;\n\ta->neg=b->neg;\n\treturn(a);\n\t}']