crypto/rsa/rsa_eay.c:223: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: 12 by call to `BN_BLINDING_invert`.
Showing all 26 steps of the trace


crypto/rsa/rsa_eay.c:180:11: Call
178.   	BN_init(&ret);
179.   
180.   	if ((ctx=BN_CTX_new()) == NULL) goto err;
                 ^
181.   	num=BN_num_bytes(rsa->n);
182.   	if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL)

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/rsa/rsa_eay.c:223:8: Call
221.   
222.   	if (rsa->flags & RSA_FLAG_BLINDING)
223.   		if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err;
              ^
224.   
225.   	/* put in leading 0 bytes if the number is less than the

crypto/bn/bn_blind.c:127:1: Parameter `ctx->depth`
  125.   	}
  126.   
  127. > int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx)
  128.   	{
  129.   	int ret;

crypto/bn/bn_blind.c:137:11: Call
  135.   		return(0);
  136.   		}
  137.   	if ((ret=BN_mod_mul(n,n,b->Ai,b->mod,ctx)) >= 0)
                   ^
  138.   		{
  139.   		if (!BN_BLINDING_update(b,ctx))

crypto/bn/bn_exp.c:127:1: Parameter `ctx->depth`
    125.   
    126.   /* slow but works */
    127. > int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
    128.   	{
    129.   	BIGNUM *t;

crypto/bn/bn_exp.c:136:2: Call
    134.   	bn_check_top(m);
    135.   
    136.   	BN_CTX_start(ctx);
            ^
    137.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
    138.   	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:137:11: Call
    135.   
    136.   	BN_CTX_start(ctx);
    137.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
                     ^
    138.   	if (a == b)
    139.   		{ if (!BN_sqr(t,a,ctx)) goto err; }

crypto/bn/bn_ctx.c:115:1: Parameter `ctx->depth`
      113.   	}
      114.   
      115. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
      116.   	{
      117.   	if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)

crypto/bn/bn_exp.c:139:10: Call
    137.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
    138.   	if (a == b)
    139.   		{ if (!BN_sqr(t,a,ctx)) goto err; }
                    ^
    140.   	else
    141.   		{ if (!BN_mul(t,a,b,ctx)) goto err; }

crypto/bn/bn_sqr.c:65:1: Parameter `ctx->depth`
      63.   /* r must not be a */
      64.   /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
      65. > int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)
      66.   	{
      67.   	int max,al;

crypto/bn/bn_sqr.c:83:2: Call
      81.   		}
      82.   
      83.   	BN_CTX_start(ctx);
             ^
      84.   	rr=(a != r) ? r : BN_CTX_get(ctx);
      85.   	tmp=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_sqr.c:85:6: Call
      83.   	BN_CTX_start(ctx);
      84.   	rr=(a != r) ? r : BN_CTX_get(ctx);
      85.   	tmp=BN_CTX_get(ctx);
                 ^
      86.   	if (tmp == NULL) goto err;
      87.   

crypto/bn/bn_ctx.c:115:1: Parameter `ctx->depth`
        113.   	}
        114.   
        115. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
        116.   	{
        117.   	if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)

crypto/bn/bn_sqr.c:148:2: Call
      146.   	ret = 1;
      147.    err:
      148.   	BN_CTX_end(ctx);
              ^
      149.   	return(ret);
      150.   	}

crypto/bn/bn_ctx.c:130:1: <Offset trace>
128.   	}
129.   
130. > void BN_CTX_end(BN_CTX *ctx)
131.   	{
132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:130:1: Parameter `ctx->depth`
        128.   	}
        129.   
        130. > void BN_CTX_end(BN_CTX *ctx)
        131.   	{
        132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:141:2: Assignment
        139.   
        140.   	ctx->too_many = 0;
        141.   	ctx->depth--;
                ^
        142.   	if (ctx->depth < BN_CTX_NUM_POS)
        143.   		ctx->tos = ctx->pos[ctx->depth];

crypto/bn/bn_ctx.c:130:1: <Length trace>
128.   	}
129.   
130. > void BN_CTX_end(BN_CTX *ctx)
131.   	{
132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:130:1: Parameter `ctx->pos[*]`
        128.   	}
        129.   
        130. > void BN_CTX_end(BN_CTX *ctx)
        131.   	{
        132.   	if (ctx == NULL) return;

crypto/bn/bn_ctx.c:143:14: Array access: Offset: [-1, +oo] Size: 12 by call to `BN_BLINDING_invert` 
        141.   	ctx->depth--;
        142.   	if (ctx->depth < BN_CTX_NUM_POS)
        143.   		ctx->tos = ctx->pos[ctx->depth];
                            ^
        144.   	}

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 RSA_eay_private_encrypt(int flen, unsigned char *from,\n\t     unsigned char *to, RSA *rsa, int padding)\n\t{\n\tBIGNUM f,ret;\n\tint i,j,k,num=0,r= -1;\n\tunsigned char *buf=NULL;\n\tBN_CTX *ctx=NULL;\n\tBN_init(&f);\n\tBN_init(&ret);\n\tif ((ctx=BN_CTX_new()) == NULL) goto err;\n\tnum=BN_num_bytes(rsa->n);\n\tif ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tswitch (padding)\n\t\t{\n\tcase RSA_PKCS1_PADDING:\n\t\ti=RSA_padding_add_PKCS1_type_1(buf,num,from,flen);\n\t\tbreak;\n\tcase RSA_NO_PADDING:\n\t\ti=RSA_padding_add_none(buf,num,from,flen);\n\t\tbreak;\n\tcase RSA_SSLV23_PADDING:\n\tdefault:\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_UNKNOWN_PADDING_TYPE);\n\t\tgoto err;\n\t\t}\n\tif (i <= 0) goto err;\n\tif (BN_bin2bn(buf,num,&f) == NULL) goto err;\n\tif ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))\n\t\tRSA_blinding_on(rsa,ctx);\n\tif (rsa->flags & RSA_FLAG_BLINDING)\n\t\tif (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;\n\tif ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||\n\t\t((rsa->p != NULL) &&\n\t\t(rsa->q != NULL) &&\n\t\t(rsa->dmp1 != NULL) &&\n\t\t(rsa->dmq1 != NULL) &&\n\t\t(rsa->iqmp != NULL)) )\n\t\t{ if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; }\n\telse\n\t\t{\n\t\tif (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err;\n\t\t}\n\tif (rsa->flags & RSA_FLAG_BLINDING)\n\t\tif (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err;\n\tj=BN_num_bytes(&ret);\n\ti=BN_bn2bin(&ret,&(to[num-j]));\n\tfor (k=0; k<(num-i); k++)\n\t\tto[k]=0;\n\tr=num;\nerr:\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tBN_clear_free(&ret);\n\tBN_clear_free(&f);\n\tif (buf != NULL)\n\t\t{\n\t\tmemset(buf,0,num);\n\t\tOPENSSL_free(buf);\n\t\t}\n\treturn(r);\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_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx)\n\t{\n\tint ret;\n\tbn_check_top(n);\n\tif ((b->A == NULL) || (b->Ai == NULL))\n\t\t{\n\t\tBNerr(BN_F_BN_BLINDING_INVERT,BN_R_NOT_INITIALIZED);\n\t\treturn(0);\n\t\t}\n\tif ((ret=BN_mod_mul(n,n,b->Ai,b->mod,ctx)) >= 0)\n\t\t{\n\t\tif (!BN_BLINDING_update(b,ctx))\n\t\t\treturn(0);\n\t\t}\n\treturn(ret);\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\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}', 'int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)\n\t{\n\tint max,al;\n\tint ret = 0;\n\tBIGNUM *tmp,*rr;\n#ifdef BN_COUNT\nprintf("BN_sqr %d * %d\\n",a->top,a->top);\n#endif\n\tbn_check_top(a);\n\tal=a->top;\n\tif (al <= 0)\n\t\t{\n\t\tr->top=0;\n\t\treturn(1);\n\t\t}\n\tBN_CTX_start(ctx);\n\trr=(a != r) ? r : BN_CTX_get(ctx);\n\ttmp=BN_CTX_get(ctx);\n\tif (tmp == NULL) goto err;\n\tmax=(al+al);\n\tif (bn_wexpand(rr,max+1) == NULL) goto err;\n\tr->neg=0;\n\tif (al == 4)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[8];\n\t\tbn_sqr_normal(rr->d,a->d,4,t);\n#else\n\t\tbn_sqr_comba4(rr->d,a->d);\n#endif\n\t\t}\n\telse if (al == 8)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[16];\n\t\tbn_sqr_normal(rr->d,a->d,8,t);\n#else\n\t\tbn_sqr_comba8(rr->d,a->d);\n#endif\n\t\t}\n\telse\n\t\t{\n#if defined(BN_RECURSION)\n\t\tif (al < BN_SQR_RECURSIVE_SIZE_NORMAL)\n\t\t\t{\n\t\t\tBN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2];\n\t\t\tbn_sqr_normal(rr->d,a->d,al,t);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tint j,k;\n\t\t\tj=BN_num_bits_word((BN_ULONG)al);\n\t\t\tj=1<<(j-1);\n\t\t\tk=j+j;\n\t\t\tif (al == j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(a,k*2) == NULL) goto err;\n\t\t\t\tif (bn_wexpand(tmp,k*2) == NULL) goto err;\n\t\t\t\tbn_sqr_recursive(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\t\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\t}\n#else\n\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n#endif\n\t\t}\n\trr->top=max;\n\tif ((max > 0) && (rr->d[max-1] == 0)) rr->top--;\n\tif (rr != r) BN_copy(r,rr);\n\tret = 1;\n err:\n\tBN_CTX_end(ctx);\n\treturn(ret);\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}']