ssl/s3_enc.c:308: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, +oo] by call to `ssl3_generate_key_block`.
Showing all 13 steps of the trace


ssl/s3_enc.c:276:1: Global `n_cipher.iv_len`
274.   	}
275.   
276. > int ssl3_setup_key_block(SSL *s)
277.   	{
278.   	unsigned char *p;

ssl/s3_enc.c:297:2: Assignment
295.   	s->s3->tmp.new_compression=comp;
296.   
297.   	num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c);
        ^
298.   	num*=2;
299.   

ssl/s3_enc.c:298:2: Assignment
296.   
297.   	num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c);
298.   	num*=2;
        ^
299.   
300.   	ssl3_cleanup_key_block(s);

ssl/s3_enc.c:302:26: Array declaration
300.   	ssl3_cleanup_key_block(s);
301.   
302.   	if ((p=(unsigned char *)Malloc(num)) == NULL)
                                ^
303.   		goto err;
304.   

ssl/s3_enc.c:302:7: Assignment
300.   	ssl3_cleanup_key_block(s);
301.   
302.   	if ((p=(unsigned char *)Malloc(num)) == NULL)
             ^
303.   		goto err;
304.   

ssl/s3_enc.c:308:2: Call
306.   	s->s3->tmp.key_block=p;
307.   
308.   	ssl3_generate_key_block(s,p,num);
        ^
309.   
310.   	return(1);

ssl/s3_enc.c:86:1: Parameter `*km`
  84.   #endif
  85.   
  86. > static void ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
  87.   	{
  88.   	MD5_CTX m5;

ssl/s3_enc.c:119:4: Call
  117.   			}
  118.   		else
  119.   			MD5_Final(km,&m5);
            ^
  120.   
  121.   		km+=MD5_DIGEST_LENGTH;

crypto/md5/md5_dgst.c:362:1: <Length trace>
360.   #endif
361.   
362. > void MD5_Final(unsigned char *md, MD5_CTX *c)
363.   	{
364.   	register int i,j;

crypto/md5/md5_dgst.c:362:1: Parameter `*md`
    360.   #endif
    361.   
    362. > void MD5_Final(unsigned char *md, MD5_CTX *c)
    363.   	{
    364.   	register int i,j;

crypto/md5/md5_dgst.c:404:2: Assignment
    402.   	p[MD5_LBLOCK-1]=c->Nh;
    403.   	md5_block(c,p,64);
    404.   	cp=md;
            ^
    405.   	l=c->A; l2c(l,cp);
    406.   	l=c->B; l2c(l,cp);

crypto/md5/md5_dgst.c:405:10: Assignment
    403.   	md5_block(c,p,64);
    404.   	cp=md;
    405.   	l=c->A; l2c(l,cp);
                    ^
    406.   	l=c->B; l2c(l,cp);
    407.   	l=c->C; l2c(l,cp);

crypto/md5/md5_dgst.c:405:10: Array access: Offset: [1, +oo] Size: [0, +oo] by call to `ssl3_generate_key_block` 
    403.   	md5_block(c,p,64);
    404.   	cp=md;
    405.   	l=c->A; l2c(l,cp);
                    ^
    406.   	l=c->B; l2c(l,cp);
    407.   	l=c->C; l2c(l,cp);

void MD5_Final(unsigned char *md, MD5_CTX *c)
	{
	register int i,j;
	register ULONG l;
	register ULONG *p;
	static unsigned char end[4]={0x80,0x00,0x00,0x00};
	unsigned char *cp=end;
	p=c->data;
	j=c->num;
	i=j>>2;
#ifdef PURIFY
	if ((j&0x03) == 0) p[i]=0;
#endif
	l=p[i];
	p_c2l(cp,l,j&0x03);
	p[i]=l;
	i++;
	if (c->num >= MD5_LAST_BLOCK)
		{
		for (; i<MD5_LBLOCK; i++)
			p[i]=0;
		md5_block(c,p,64);
		i=0;
		}
	for (; i<(MD5_LBLOCK-2); i++)
		p[i]=0;
	p[MD5_LBLOCK-2]=c->Nl;
	p[MD5_LBLOCK-1]=c->Nh;
	md5_block(c,p,64);
	cp=md;
	l=c->A; l2c(l,cp);
	l=c->B; l2c(l,cp);
	l=c->C; l2c(l,cp);
	l=c->D; l2c(l,cp);
	c->num=0;
	}
['int ssl3_setup_key_block(SSL *s)\n\t{\n\tunsigned char *p;\n\tconst EVP_CIPHER *c;\n\tconst EVP_MD *hash;\n\tint num;\n\tSSL_COMP *comp;\n\tif (s->s3->tmp.key_block_length != 0)\n\t\treturn(1);\n\tif (!ssl_cipher_get_evp(s->session,&c,&hash,&comp))\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,SSL_R_CIPHER_OR_HASH_UNAVAILABLE);\n\t\treturn(0);\n\t\t}\n\ts->s3->tmp.new_sym_enc=c;\n\ts->s3->tmp.new_hash=hash;\n\ts->s3->tmp.new_compression=comp;\n\tnum=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c);\n\tnum*=2;\n\tssl3_cleanup_key_block(s);\n\tif ((p=(unsigned char *)Malloc(num)) == NULL)\n\t\tgoto err;\n\ts->s3->tmp.key_block_length=num;\n\ts->s3->tmp.key_block=p;\n\tssl3_generate_key_block(s,p,num);\n\treturn(1);\nerr:\n\tSSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE);\n\treturn(0);\n\t}', "static void ssl3_generate_key_block(SSL *s, unsigned char *km, int num)\n\t{\n\tMD5_CTX m5;\n\tSHA_CTX s1;\n\tunsigned char buf[8],smd[SHA_DIGEST_LENGTH];\n\tunsigned char c='A';\n\tint i,j,k;\n\tk=0;\n\tfor (i=0; i<num; i+=MD5_DIGEST_LENGTH)\n\t\t{\n\t\tk++;\n\t\tfor (j=0; j<k; j++)\n\t\t\tbuf[j]=c;\n\t\tc++;\n\t\tSHA1_Init(  &s1);\n\t\tSHA1_Update(&s1,buf,k);\n\t\tSHA1_Update(&s1,s->session->master_key,\n\t\t\ts->session->master_key_length);\n\t\tSHA1_Update(&s1,s->s3->server_random,SSL3_RANDOM_SIZE);\n\t\tSHA1_Update(&s1,s->s3->client_random,SSL3_RANDOM_SIZE);\n\t\tSHA1_Final( smd,&s1);\n\t\tMD5_Init(  &m5);\n\t\tMD5_Update(&m5,s->session->master_key,\n\t\t\ts->session->master_key_length);\n\t\tMD5_Update(&m5,smd,SHA_DIGEST_LENGTH);\n\t\tif ((i+MD5_DIGEST_LENGTH) > num)\n\t\t\t{\n\t\t\tMD5_Final(smd,&m5);\n\t\t\tmemcpy(km,smd,(num-i));\n\t\t\t}\n\t\telse\n\t\t\tMD5_Final(km,&m5);\n\t\tkm+=MD5_DIGEST_LENGTH;\n\t\t}\n\tmemset(smd,0,SHA_DIGEST_LENGTH);\n\t}", 'void MD5_Final(unsigned char *md, MD5_CTX *c)\n\t{\n\tregister int i,j;\n\tregister ULONG l;\n\tregister ULONG *p;\n\tstatic unsigned char end[4]={0x80,0x00,0x00,0x00};\n\tunsigned char *cp=end;\n\tp=c->data;\n\tj=c->num;\n\ti=j>>2;\n#ifdef PURIFY\n\tif ((j&0x03) == 0) p[i]=0;\n#endif\n\tl=p[i];\n\tp_c2l(cp,l,j&0x03);\n\tp[i]=l;\n\ti++;\n\tif (c->num >= MD5_LAST_BLOCK)\n\t\t{\n\t\tfor (; i<MD5_LBLOCK; i++)\n\t\t\tp[i]=0;\n\t\tmd5_block(c,p,64);\n\t\ti=0;\n\t\t}\n\tfor (; i<(MD5_LBLOCK-2); i++)\n\t\tp[i]=0;\n\tp[MD5_LBLOCK-2]=c->Nl;\n\tp[MD5_LBLOCK-1]=c->Nh;\n\tmd5_block(c,p,64);\n\tcp=md;\n\tl=c->A; l2c(l,cp);\n\tl=c->B; l2c(l,cp);\n\tl=c->C; l2c(l,cp);\n\tl=c->D; l2c(l,cp);\n\tc->num=0;\n\t}']