crypto/rsa/rsa_eay.c:310: error: BUFFER_OVERRUN_L3
  Offset: [-7, +oo] (⇐ [1, +oo] + -8) Size: [0, +oo] by call to `RSA_padding_check_SSLv23`.
Showing all 13 steps of the trace


crypto/rsa/rsa_eay.c:256:6: Call
254.   	if (ctx == NULL) goto err;
255.   
256.   	num=BN_num_bytes(rsa->n);
            ^
257.   
258.   	if ((buf=(unsigned char *)Malloc(num)) == NULL)

crypto/bn/bn_lib.c:245:19: Assignment
  243.   	bn_check_top(a);
  244.   
  245.   	if (a->top == 0) return(0);
                           ^
  246.   	l=a->d[a->top-1];
  247.   	i=(a->top-1)*BN_BITS2;

crypto/rsa/rsa_eay.c:256:2: Assignment
254.   	if (ctx == NULL) goto err;
255.   
256.   	num=BN_num_bytes(rsa->n);
        ^
257.   
258.   	if ((buf=(unsigned char *)Malloc(num)) == NULL)

crypto/rsa/rsa_eay.c:258:28: Array declaration
256.   	num=BN_num_bytes(rsa->n);
257.   
258.   	if ((buf=(unsigned char *)Malloc(num)) == NULL)
                                  ^
259.   		{
260.   		RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_eay.c:258:7: Assignment
256.   	num=BN_num_bytes(rsa->n);
257.   
258.   	if ((buf=(unsigned char *)Malloc(num)) == NULL)
             ^
259.   		{
260.   		RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_eay.c:310:5: Call
308.   #endif
309.    	case RSA_SSLV23_PADDING:
310.   		r=RSA_padding_check_SSLv23(to,num,buf,j,num);
           ^
311.   		break;
312.   	case RSA_NO_PADDING:

crypto/rsa/rsa_ssl.c:131:7: <Offset trace>
129.   		return(-1);
130.   		}
131.   	for (k= -8; k<0; k++)
             ^
132.   		{
133.   		if (p[k] !=  0x03) break;

crypto/rsa/rsa_ssl.c:131:7: Assignment
  129.   		return(-1);
  130.   		}
  131.   	for (k= -8; k<0; k++)
               ^
  132.   		{
  133.   		if (p[k] !=  0x03) break;

crypto/rsa/rsa_ssl.c:103:1: <Length trace>
101.   	}
102.   
103. > int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,
104.   	     int flen, int num)
105.   	{

crypto/rsa/rsa_ssl.c:103:1: Parameter `*from`
  101.   	}
  102.   
  103. > int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,
  104.   	     int flen, int num)
  105.   	{

crypto/rsa/rsa_ssl.c:109:2: Assignment
  107.   	unsigned char *p;
  108.   
  109.   	p=from;
          ^
  110.   	if (flen < 10)
  111.   		{

crypto/rsa/rsa_ssl.c:115:30: Assignment
  113.   		return(-1);
  114.   		}
  115.   	if ((num != (flen+1)) || (*(p++) != 02))
                                      ^
  116.   		{
  117.   		RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_BLOCK_TYPE_IS_NOT_02);

crypto/rsa/rsa_ssl.c:133:7: Array access: Offset: [-7, +oo] (⇐ [1, +oo] + -8) Size: [0, +oo] by call to `RSA_padding_check_SSLv23` 
  131.   	for (k= -8; k<0; k++)
  132.   		{
  133.   		if (p[k] !=  0x03) break;
               ^
  134.   		}
  135.   	if (k == 0)

int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,
	     int flen, int num)
	{
	int i,j,k;
	unsigned char *p;
	p=from;
	if (flen < 10)
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_DATA_TOO_SMALL);
		return(-1);
		}
	if ((num != (flen+1)) || (*(p++) != 02))
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_BLOCK_TYPE_IS_NOT_02);
		return(-1);
		}
	j=flen-1;
	for (i=0; i<j; i++)
		if (*(p++) == 0) break;
	if ((i == j) || (i < 8))
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_NULL_BEFORE_BLOCK_MISSING);
		return(-1);
		}
	for (k= -8; k<0; k++)
		{
		if (p[k] !=  0x03) break;
		}
	if (k == 0)
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_SSLV3_ROLLBACK_ATTACK);
		return(-1);
		}
	i++;
	j-=i;
	memcpy(to,p,(unsigned int)j);
	return(j);
	}
['static int RSA_eay_private_decrypt(int flen, unsigned char *from,\n\t     unsigned char *to, RSA *rsa, int padding)\n\t{\n\tBIGNUM f,ret;\n\tint j,num=0,r= -1;\n\tunsigned char *p;\n\tunsigned char *buf=NULL;\n\tBN_CTX *ctx=NULL;\n\tBN_init(&f);\n\tBN_init(&ret);\n\tctx=BN_CTX_new();\n\tif (ctx == NULL) goto err;\n\tnum=BN_num_bytes(rsa->n);\n\tif ((buf=(unsigned char *)Malloc(num)) == NULL)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tif (flen > num)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN);\n\t\tgoto err;\n\t\t}\n\tif (BN_bin2bn(from,(int)flen,&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 (\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))\n\t\t\tgoto err;\n\t\t}\n\tif (rsa->flags & RSA_FLAG_BLINDING)\n\t\tif (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err;\n\tp=buf;\n\tj=BN_bn2bin(&ret,p);\n\tswitch (padding)\n\t\t{\n\tcase RSA_PKCS1_PADDING:\n\t\tr=RSA_padding_check_PKCS1_type_2(to,num,buf,j,num);\n\t\tbreak;\n#ifndef NO_SHA\n        case RSA_PKCS1_OAEP_PADDING:\n\t        r=RSA_padding_check_PKCS1_OAEP(to,num,buf,j,num,NULL,0);\n                break;\n#endif\n \tcase RSA_SSLV23_PADDING:\n\t\tr=RSA_padding_check_SSLv23(to,num,buf,j,num);\n\t\tbreak;\n\tcase RSA_NO_PADDING:\n\t\tr=RSA_padding_check_none(to,num,buf,j,num);\n\t\tbreak;\n\tdefault:\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE);\n\t\tgoto err;\n\t\t}\n\tif (r < 0)\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_PADDING_CHECK_FAILED);\nerr:\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tBN_clear_free(&f);\n\tBN_clear_free(&ret);\n\tif (buf != NULL)\n\t\t{\n\t\tmemset(buf,0,num);\n\t\tFree(buf);\n\t\t}\n\treturn(r);\n\t}', 'int BN_num_bits(BIGNUM *a)\n\t{\n\tBN_ULONG l;\n\tint i;\n\tbn_check_top(a);\n\tif (a->top == 0) return(0);\n\tl=a->d[a->top-1];\n\ti=(a->top-1)*BN_BITS2;\n\tif (l == 0)\n\t\t{\n#if !defined(NO_STDIO) && !defined(WIN16)\n\t\tfprintf(stderr,"BAD TOP VALUE\\n");\n#endif\n\t\tabort();\n\t\t}\n\treturn(i+BN_num_bits_word(l));\n\t}', 'int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from,\n\t     int flen, int num)\n\t{\n\tint i,j,k;\n\tunsigned char *p;\n\tp=from;\n\tif (flen < 10)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_DATA_TOO_SMALL);\n\t\treturn(-1);\n\t\t}\n\tif ((num != (flen+1)) || (*(p++) != 02))\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_BLOCK_TYPE_IS_NOT_02);\n\t\treturn(-1);\n\t\t}\n\tj=flen-1;\n\tfor (i=0; i<j; i++)\n\t\tif (*(p++) == 0) break;\n\tif ((i == j) || (i < 8))\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_NULL_BEFORE_BLOCK_MISSING);\n\t\treturn(-1);\n\t\t}\n\tfor (k= -8; k<0; k++)\n\t\t{\n\t\tif (p[k] !=  0x03) break;\n\t\t}\n\tif (k == 0)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23,RSA_R_SSLV3_ROLLBACK_ATTACK);\n\t\treturn(-1);\n\t\t}\n\ti++;\n\tj-=i;\n\tmemcpy(to,p,(unsigned int)j);\n\treturn(j);\n\t}']