crypto/rsa/rsa_eay.c:389: error: BUFFER_OVERRUN_L3
  Offset: 1 Size: [0, +oo] by call to `RSA_padding_check_PKCS1_type_1`.
Showing all 11 steps of the trace


crypto/rsa/rsa_eay.c:355:6: Call
353.   	if (ctx == NULL) goto err;
354.   
355.   	num=BN_num_bytes(rsa->n);
            ^
356.   	buf=(unsigned char *)Malloc(num);
357.   	if (buf == 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:355:2: Assignment
353.   	if (ctx == NULL) goto err;
354.   
355.   	num=BN_num_bytes(rsa->n);
        ^
356.   	buf=(unsigned char *)Malloc(num);
357.   	if (buf == NULL)

crypto/rsa/rsa_eay.c:356:23: Array declaration
354.   
355.   	num=BN_num_bytes(rsa->n);
356.   	buf=(unsigned char *)Malloc(num);
                             ^
357.   	if (buf == NULL)
358.   		{

crypto/rsa/rsa_eay.c:356:2: Assignment
354.   
355.   	num=BN_num_bytes(rsa->n);
356.   	buf=(unsigned char *)Malloc(num);
        ^
357.   	if (buf == NULL)
358.   		{

crypto/rsa/rsa_eay.c:389:5: Call
387.   		{
388.   	case RSA_PKCS1_PADDING:
389.   		r=RSA_padding_check_PKCS1_type_1(to,num,buf,i,num);
           ^
390.   		break;
391.   	case RSA_NO_PADDING:

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

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

crypto/rsa/rsa_pk1.c:109:2: Assignment
  107.   	unsigned char *p;
  108.   
  109.   	p=from;
          ^
  110.   	if ((num != (flen+1)) || (*(p++) != 01))
  111.   		{

crypto/rsa/rsa_pk1.c:110:30: Assignment
  108.   
  109.   	p=from;
  110.   	if ((num != (flen+1)) || (*(p++) != 01))
                                      ^
  111.   		{
  112.   		RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BLOCK_TYPE_IS_NOT_01);

crypto/rsa/rsa_pk1.c:120:7: Array access: Offset: 1 Size: [0, +oo] by call to `RSA_padding_check_PKCS1_type_1` 
  118.   	for (i=0; i<j; i++)
  119.   		{
  120.   		if (*p != 0xff) /* should decrypt to 0xff */
               ^
  121.   			{
  122.   			if (*p == 0)

int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
	     unsigned char *from, int flen, int num)
	{
	int i,j;
	unsigned char *p;
	p=from;
	if ((num != (flen+1)) || (*(p++) != 01))
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BLOCK_TYPE_IS_NOT_01);
		return(-1);
		}
	j=flen-1;
	for (i=0; i<j; i++)
		{
		if (*p != 0xff)
			{
			if (*p == 0)
				{ p++; break; }
			else	{
				RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BAD_FIXED_HEADER_DECRYPT);
				return(-1);
				}
			}
		p++;
		}
	if (i == j)
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_NULL_BEFORE_BLOCK_MISSING);
		return(-1);
		}
	if (i < 8)
		{
		RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BAD_PAD_BYTE_COUNT);
		return(-1);
		}
	i++;
	j-=i;
	memcpy(to,p,(unsigned int)j);
	return(j);
	}
['static int RSA_eay_public_decrypt(int flen, unsigned char *from,\n\t     unsigned char *to, RSA *rsa, int padding)\n\t{\n\tBIGNUM f,ret;\n\tint i,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\tbuf=(unsigned char *)Malloc(num);\n\tif (buf == NULL)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_EAY_PUBLIC_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_PUBLIC_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN);\n\t\tgoto err;\n\t\t}\n\tif (BN_bin2bn(from,flen,&f) == NULL) goto err;\n\tif ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))\n\t\t{\n\t\tif ((rsa->_method_mod_n=BN_MONT_CTX_new()) != NULL)\n\t\t\tif (!BN_MONT_CTX_set(rsa->_method_mod_n,rsa->n,ctx))\n\t\t\t    goto err;\n\t\t}\n\tif (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx,\n\t\trsa->_method_mod_n)) goto err;\n\tp=buf;\n\ti=BN_bn2bin(&ret,p);\n\tswitch (padding)\n\t\t{\n\tcase RSA_PKCS1_PADDING:\n\t\tr=RSA_padding_check_PKCS1_type_1(to,num,buf,i,num);\n\t\tbreak;\n\tcase RSA_NO_PADDING:\n\t\tr=RSA_padding_check_none(to,num,buf,i,num);\n\t\tbreak;\n\tdefault:\n\t\tRSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE);\n\t\tgoto err;\n\t\t}\n\tif (r < 0)\n\t\tRSAerr(RSA_F_RSA_EAY_PUBLIC_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_PKCS1_type_1(unsigned char *to, int tlen,\n\t     unsigned char *from, int flen, int num)\n\t{\n\tint i,j;\n\tunsigned char *p;\n\tp=from;\n\tif ((num != (flen+1)) || (*(p++) != 01))\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BLOCK_TYPE_IS_NOT_01);\n\t\treturn(-1);\n\t\t}\n\tj=flen-1;\n\tfor (i=0; i<j; i++)\n\t\t{\n\t\tif (*p != 0xff)\n\t\t\t{\n\t\t\tif (*p == 0)\n\t\t\t\t{ p++; break; }\n\t\t\telse\t{\n\t\t\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BAD_FIXED_HEADER_DECRYPT);\n\t\t\t\treturn(-1);\n\t\t\t\t}\n\t\t\t}\n\t\tp++;\n\t\t}\n\tif (i == j)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_NULL_BEFORE_BLOCK_MISSING);\n\t\treturn(-1);\n\t\t}\n\tif (i < 8)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,RSA_R_BAD_PAD_BYTE_COUNT);\n\t\treturn(-1);\n\t\t}\n\ti++;\n\tj-=i;\n\tmemcpy(to,p,(unsigned int)j);\n\treturn(j);\n\t}']