crypto/rsa/rsa_oaep.c:147: error: BUFFER_OVERRUN_L1
  Offset: [4, +oo] Size: 4 by call to `SHA1_Update`.
Showing all 9 steps of the trace


crypto/rsa/rsa_oaep.c:134:1: Array declaration
132.       }
133.   
134. > int MGF1(unsigned char *mask, long len, unsigned char *seed, long seedlen)
135.       {
136.       long i, outlen = 0;

crypto/rsa/rsa_oaep.c:147:2: Call
145.   	SHA1_Init(&c);
146.   	SHA1_Update(&c, seed, seedlen);
147.   	SHA1_Update(&c, cnt, 4);
        ^
148.   	if (outlen + SHA_DIGEST_LENGTH <= len)
149.   	    {

crypto/sha/sha1dgst.c:117:1: <Length trace>
115.   	}
116.   
117. > void SHA1_Update(SHA_CTX *c, register const unsigned char *data,
118.   	     unsigned long len)
119.   	{

crypto/sha/sha1dgst.c:117:1: Parameter `*data`
  115.   	}
  116.   
  117. > void SHA1_Update(SHA_CTX *c, register const unsigned char *data,
  118.   	     unsigned long len)
  119.   	{

crypto/sha/sha1dgst.c:141:4: Assignment
  139.   			{
  140.   			l= p[sw];
  141.   			M_p_c2nl(data,l,sc);
            ^
  142.   			p[sw++]=l;
  143.   			for (; sw<SHA_LBLOCK; sw++)

crypto/sha/sha1dgst.c:145:5: Assignment
  143.   			for (; sw<SHA_LBLOCK; sw++)
  144.   				{
  145.   				M_c2nl(data,l);
             ^
  146.   				p[sw]=l;
  147.   				}

crypto/sha/sha1dgst.c:145:5: Assignment
  143.   			for (; sw<SHA_LBLOCK; sw++)
  144.   				{
  145.   				M_c2nl(data,l);
             ^
  146.   				p[sw]=l;
  147.   				}

crypto/sha/sha1dgst.c:145:5: Assignment
  143.   			for (; sw<SHA_LBLOCK; sw++)
  144.   				{
  145.   				M_c2nl(data,l);
             ^
  146.   				p[sw]=l;
  147.   				}

crypto/sha/sha1dgst.c:145:5: Array access: Offset: [4, +oo] Size: 4 by call to `SHA1_Update` 
  143.   			for (; sw<SHA_LBLOCK; sw++)
  144.   				{
  145.   				M_c2nl(data,l);
             ^
  146.   				p[sw]=l;
  147.   				}

void SHA1_Update(SHA_CTX *c, register const unsigned char *data,
	     unsigned long len)
	{
	register SHA_LONG *p;
	int ew,ec,sw,sc;
	SHA_LONG l;
	if (len == 0) return;
	l=(c->Nl+(len<<3))&0xffffffffL;
	if (l < c->Nl)
		c->Nh++;
	c->Nh+=(len>>29);
	c->Nl=l;
	if (c->num != 0)
		{
		p=c->data;
		sw=c->num>>2;
		sc=c->num&0x03;
		if ((c->num+len) >= SHA_CBLOCK)
			{
			l= p[sw];
			M_p_c2nl(data,l,sc);
			p[sw++]=l;
			for (; sw<SHA_LBLOCK; sw++)
				{
				M_c2nl(data,l);
				p[sw]=l;
				}
			len-=(SHA_CBLOCK-c->num);
			sha1_block(c,p,1);
			c->num=0;
			}
		else
			{
			c->num+=(int)len;
			if ((sc+len) < 4)
				{
				l= p[sw];
				M_p_c2nl_p(data,l,sc,len);
				p[sw]=l;
				}
			else
				{
				ew=(c->num>>2);
				ec=(c->num&0x03);
				l= p[sw];
				M_p_c2nl(data,l,sc);
				p[sw++]=l;
				for (; sw < ew; sw++)
					{ M_c2nl(data,l); p[sw]=l; }
				if (ec)
					{
					M_c2nl_p(data,l,ec);
					p[sw]=l;
					}
				}
			return;
			}
		}
#if SHA_LONG_LOG2==2
#if defined(B_ENDIAN) || defined(SHA1_ASM)
	if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
		{
		sw=len/SHA_CBLOCK;
		if (sw)
			{
			sha1_block(c,(SHA_LONG *)data,sw);
			sw*=SHA_CBLOCK;
			data+=sw;
			len-=sw;
			}
		}
#endif
#endif
	p=c->data;
	while (len >= SHA_CBLOCK)
		{
#if SHA_LONG_LOG2==2
#if defined(B_ENDIAN) || defined(SHA1_ASM)
#define SHA_NO_TAIL_CODE
		if (p != (SHA_LONG *)data)
			memcpy(p,data,SHA_CBLOCK);
		data+=SHA_CBLOCK;
		sha1_block(c,p=c->data,1);
		len-=SHA_CBLOCK;
#elif defined(L_ENDIAN)
#define BE_COPY(dst,src,i)	{				\
				l = ((SHA_LONG *)src)[i];	\
				Endian_Reverse32(l);		\
				dst[i] = l;			\
				}
		if ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)
			{
			for (sw=(SHA_LBLOCK/4); sw; sw--)
				{
				BE_COPY(p,data,0);
				BE_COPY(p,data,1);
				BE_COPY(p,data,2);
				BE_COPY(p,data,3);
				p+=4;
				data += 4*sizeof(SHA_LONG);
				}
			sha1_block(c,p=c->data,1);
			len-=SHA_CBLOCK;
			continue;
			}
#endif
#endif
#ifndef SHA_NO_TAIL_CODE
		p=c->data;
		for (sw=(SHA_LBLOCK/4); sw; sw--)
			{
			M_c2nl(data,l); p[0]=l;
			M_c2nl(data,l); p[1]=l;
			M_c2nl(data,l); p[2]=l;
			M_c2nl(data,l); p[3]=l;
			p+=4;
			}
		p=c->data;
		sha1_block(c,p,1);
		len-=SHA_CBLOCK;
#endif
		}
	ec=(int)len;
	c->num=ec;
	ew=(ec>>2);
	ec&=0x03;
	for (sw=0; sw < ew; sw++)
		{ M_c2nl(data,l); p[sw]=l; }
	M_c2nl_p(data,l,ec);
	p[sw]=l;
	}
['int MGF1(unsigned char *mask, long len, unsigned char *seed, long seedlen)\n    {\n    long i, outlen = 0;\n    unsigned char cnt[4];\n    SHA_CTX c;\n    unsigned char md[SHA_DIGEST_LENGTH];\n    for (i = 0; outlen < len; i++)\n\t{\n\tcnt[0] = (i >> 24) & 255, cnt[1] = (i >> 16) & 255,\n\t  cnt[2] = (i >> 8) & 255, cnt[3] = i & 255;\n\tSHA1_Init(&c);\n\tSHA1_Update(&c, seed, seedlen);\n\tSHA1_Update(&c, cnt, 4);\n\tif (outlen + SHA_DIGEST_LENGTH <= len)\n\t    {\n\t    SHA1_Final(mask + outlen, &c);\n\t    outlen += SHA_DIGEST_LENGTH;\n\t    }\n\telse\n\t    {\n\t    SHA1_Final(md, &c);\n\t    memcpy(mask + outlen, md, len - outlen);\n\t    outlen = len;\n\t    }\n\t}\n    return (0);\n    }', 'void SHA1_Update(SHA_CTX *c, register const unsigned char *data,\n\t     unsigned long len)\n\t{\n\tregister SHA_LONG *p;\n\tint ew,ec,sw,sc;\n\tSHA_LONG l;\n\tif (len == 0) return;\n\tl=(c->Nl+(len<<3))&0xffffffffL;\n\tif (l < c->Nl)\n\t\tc->Nh++;\n\tc->Nh+=(len>>29);\n\tc->Nl=l;\n\tif (c->num != 0)\n\t\t{\n\t\tp=c->data;\n\t\tsw=c->num>>2;\n\t\tsc=c->num&0x03;\n\t\tif ((c->num+len) >= SHA_CBLOCK)\n\t\t\t{\n\t\t\tl= p[sw];\n\t\t\tM_p_c2nl(data,l,sc);\n\t\t\tp[sw++]=l;\n\t\t\tfor (; sw<SHA_LBLOCK; sw++)\n\t\t\t\t{\n\t\t\t\tM_c2nl(data,l);\n\t\t\t\tp[sw]=l;\n\t\t\t\t}\n\t\t\tlen-=(SHA_CBLOCK-c->num);\n\t\t\tsha1_block(c,p,1);\n\t\t\tc->num=0;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tc->num+=(int)len;\n\t\t\tif ((sc+len) < 4)\n\t\t\t\t{\n\t\t\t\tl= p[sw];\n\t\t\t\tM_p_c2nl_p(data,l,sc,len);\n\t\t\t\tp[sw]=l;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tew=(c->num>>2);\n\t\t\t\tec=(c->num&0x03);\n\t\t\t\tl= p[sw];\n\t\t\t\tM_p_c2nl(data,l,sc);\n\t\t\t\tp[sw++]=l;\n\t\t\t\tfor (; sw < ew; sw++)\n\t\t\t\t\t{ M_c2nl(data,l); p[sw]=l; }\n\t\t\t\tif (ec)\n\t\t\t\t\t{\n\t\t\t\t\tM_c2nl_p(data,l,ec);\n\t\t\t\t\tp[sw]=l;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\treturn;\n\t\t\t}\n\t\t}\n#if SHA_LONG_LOG2==2\n#if defined(B_ENDIAN) || defined(SHA1_ASM)\n\tif ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)\n\t\t{\n\t\tsw=len/SHA_CBLOCK;\n\t\tif (sw)\n\t\t\t{\n\t\t\tsha1_block(c,(SHA_LONG *)data,sw);\n\t\t\tsw*=SHA_CBLOCK;\n\t\t\tdata+=sw;\n\t\t\tlen-=sw;\n\t\t\t}\n\t\t}\n#endif\n#endif\n\tp=c->data;\n\twhile (len >= SHA_CBLOCK)\n\t\t{\n#if SHA_LONG_LOG2==2\n#if defined(B_ENDIAN) || defined(SHA1_ASM)\n#define SHA_NO_TAIL_CODE\n\t\tif (p != (SHA_LONG *)data)\n\t\t\tmemcpy(p,data,SHA_CBLOCK);\n\t\tdata+=SHA_CBLOCK;\n\t\tsha1_block(c,p=c->data,1);\n\t\tlen-=SHA_CBLOCK;\n#elif defined(L_ENDIAN)\n#define BE_COPY(dst,src,i)\t{\t\t\t\t\\\n\t\t\t\tl = ((SHA_LONG *)src)[i];\t\\\n\t\t\t\tEndian_Reverse32(l);\t\t\\\n\t\t\t\tdst[i] = l;\t\t\t\\\n\t\t\t\t}\n\t\tif ((((unsigned long)data)%sizeof(SHA_LONG)) == 0)\n\t\t\t{\n\t\t\tfor (sw=(SHA_LBLOCK/4); sw; sw--)\n\t\t\t\t{\n\t\t\t\tBE_COPY(p,data,0);\n\t\t\t\tBE_COPY(p,data,1);\n\t\t\t\tBE_COPY(p,data,2);\n\t\t\t\tBE_COPY(p,data,3);\n\t\t\t\tp+=4;\n\t\t\t\tdata += 4*sizeof(SHA_LONG);\n\t\t\t\t}\n\t\t\tsha1_block(c,p=c->data,1);\n\t\t\tlen-=SHA_CBLOCK;\n\t\t\tcontinue;\n\t\t\t}\n#endif\n#endif\n#ifndef SHA_NO_TAIL_CODE\n\t\tp=c->data;\n\t\tfor (sw=(SHA_LBLOCK/4); sw; sw--)\n\t\t\t{\n\t\t\tM_c2nl(data,l); p[0]=l;\n\t\t\tM_c2nl(data,l); p[1]=l;\n\t\t\tM_c2nl(data,l); p[2]=l;\n\t\t\tM_c2nl(data,l); p[3]=l;\n\t\t\tp+=4;\n\t\t\t}\n\t\tp=c->data;\n\t\tsha1_block(c,p,1);\n\t\tlen-=SHA_CBLOCK;\n#endif\n\t\t}\n\tec=(int)len;\n\tc->num=ec;\n\tew=(ec>>2);\n\tec&=0x03;\n\tfor (sw=0; sw < ew; sw++)\n\t\t{ M_c2nl(data,l); p[sw]=l; }\n\tM_c2nl_p(data,l,ec);\n\tp[sw]=l;\n\t}']