crypto/dh/dh_check.c:110: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: 13 by call to `BN_is_prime`.
Showing all 11 steps of the trace


crypto/dh/dh_check.c:81:6: Call
79.   
80.   	*ret=0;
81.   	ctx=BN_CTX_new();
           ^
82.   	if (ctx == NULL) goto err;
83.   	q=BN_new();

crypto/bn/bn_lib.c:319:2: Call
  317.   		}
  318.   
  319.   	BN_CTX_init(ret);
          ^
  320.   	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);

crypto/bn/bn_lib.c:327:2: Assignment
    325.   	{
    326.   	memset(ctx,0,sizeof(BN_CTX));
    327.   	ctx->tos=0;
            ^
    328.   	ctx->flags=0;
    329.   	}

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 `ctx_passed->tos`
  152.   	}
  153.   
  154. > int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,char *),
  155.   	     BN_CTX *ctx_passed, char *cb_arg)
  156.   	{

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: <Offset trace>
152.   	}
153.   
154. > int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,char *),
155.   	     BN_CTX *ctx_passed, char *cb_arg)
156.   	{

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

crypto/bn/bn_prime.c:154:1: <Length trace>
152.   	}
153.   
154. > int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,char *),
155.   	     BN_CTX *ctx_passed, char *cb_arg)
156.   	{

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

crypto/bn/bn_prime.c:172:2: Array access: Offset: [-1, +oo] Size: 13 by call to `BN_is_prime` 
  170.   	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
  171.   
  172.   	check= &(ctx->bn[ctx->tos++]);
          ^
  173.   
  174.   	/* Setup the montgomery structure */

int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,char *),
	     BN_CTX *ctx_passed, char *cb_arg)
	{
	int i,j,c2=0,ret= -1;
	BIGNUM *check;
	BN_CTX *ctx=NULL,*ctx2=NULL;
	BN_MONT_CTX *mont=NULL;
	if (!BN_is_odd(a))
		return(0);
	if (ctx_passed != NULL)
		ctx=ctx_passed;
	else
		if ((ctx=BN_CTX_new()) == NULL) goto err;
	if ((ctx2=BN_CTX_new()) == NULL) goto err;
	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
	check= &(ctx->bn[ctx->tos++]);
	if (!BN_MONT_CTX_set(mont,a,ctx2)) goto err;
	for (i=0; i<checks; i++)
		{
		if (!BN_rand(check,BN_num_bits(a)-1,0,0)) goto err;
		j=witness(check,a,ctx,ctx2,mont);
		if (j == -1) goto err;
		if (j)
			{
			ret=0;
			goto err;
			}
		if (callback != NULL) callback(1,c2++,cb_arg);
		}
	ret=1;
err:
	ctx->tos--;
	if ((ctx_passed == NULL) && (ctx != NULL))
		BN_CTX_free(ctx);
	if (ctx2 != NULL)
		BN_CTX_free(ctx2);
	if (mont != NULL) BN_MONT_CTX_free(mont);
	return(ret);
	}
['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}', 'BN_CTX *BN_CTX_new(void)\n\t{\n\tBN_CTX *ret;\n\tret=(BN_CTX *)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\tmemset(ctx,0,sizeof(BN_CTX));\n\tctx->tos=0;\n\tctx->flags=0;\n\t}', 'int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,char *),\n\t     BN_CTX *ctx_passed, char *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}']