rem: if (warning==0) { LOG(L_ERR, "ERROR: warning too big\n"); goto error01; } len += warning_len + CRLF_LEN;
add: if (warning) len += warning_len + CRLF_LEN; else LOG(L_WARN, "WARNING: warning skipped -- too big\n");
context: char * build_res_buf_from_sip_req( unsigned int code, char *text,					char *new_tag, unsigned int new_tag_len,					struct sip_msg* msg, unsigned int *returned_len){	char              *buf, *p;	unsigned int      len,foo;	struct hdr_field  *hdr;	struct lump_rpl   *lump;	int               i;	char              backup;	char              *received_buf;	unsigned int               received_len;	char              *warning;	unsigned int      warning_len;	int r;	str to_tag;	received_buf=0;	received_len=0;	buf=0;	/* make -Wall happy */	warning=0;	/* force parsing all headers -- we want to return all	Via's in the reply and they may be scattered down to the	end of header (non-block Vias are a really poor property	of SIP :( ) */	if (parse_headers( msg, HDR_EOH, 0 )==-1) {		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "			"alas, parse_headers failed\n");		goto error00;	}	/* check if received needs to be added */	backup = msg->via1->host.s[msg->via1->host.len];	msg->via1->host.s[msg->via1->host.len] = 0;	r=check_address(&msg->rcv.src_ip, msg->via1->host.s, received_dns);	msg->via1->host.s[msg->via1->host.len] = backup;	if (r!=0) {		if ((received_buf=received_builder(msg,&received_len))==0) {			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "				"alas, received_builder failed\n");			goto error00;		}	}	/*computes the lenght of the new response buffer*/	len = 0;	/* first line */	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ +		strlen(text) + CRLF_LEN/*new line*/;	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/	for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) {		if (hdr->type==HDR_TO) {			if (new_tag)			{				to_tag=get_to(msg)->tag_value;				if (to_tag.s )					len+=new_tag_len-to_tag.len;				else					len+=new_tag_len+TOTAG_TOKEN_LEN/*";tag="*/;			}		} else if (hdr->type==HDR_VIA) {				if (hdr==msg->h_via1) len += received_len;		} else if (hdr->type==HDR_RECORDROUTE) {				/* RR only for 1xx and 2xx replies */				if (code<180 || code>=300) continue;		} else if (!(hdr->type==HDR_FROM 					|| hdr->type==HDR_CALLID					|| hdr->type==HDR_CSEQ)) {			continue;		}		len += ((hdr->body.s+hdr->body.len )-hdr->name.s )+CRLF_LEN;	}	/*lumps length*/	for(lump=msg->reply_lump;lump;lump=lump->next)		len += lump->text.len;	if (server_signature) {		/*server header*/		len += SERVER_HDR_LEN + CRLF_LEN;		/*content length header*/		len +=CONTENT_LENGTH_LEN+1 + CRLF_LEN;	}	if (sip_warning) {		warning = warning_builder(msg,&warning_len);		if (warning==0) {			LOG(L_ERR, "ERROR: warning too big\n");			goto error01;		}		len += warning_len + CRLF_LEN;	}	/* end of message */	len += CRLF_LEN; /*new line*/	/*allocating mem*/	buf = (char*) pkg_malloc( len+1 );	if (!buf)	{		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: out of memory "			" ; needs %d\n",len);		goto error01;	}	/* filling the buffer*/	p=buf;	/* first line */	memcpy( p , SIP_VERSION , SIP_VERSION_LEN );	p += SIP_VERSION_LEN;	*(p++) = ' ' ;	/*code*/	for ( i=2 , foo = code  ;  i>=0  ;  i-- , foo=foo/10 )		*(p+i) = '0' + foo - ( foo/10 )*10;	p += 3;	*(p++) = ' ' ;	memcpy( p , text , strlen(text) );	p += strlen(text);	memcpy( p, CRLF, CRLF_LEN );	p+=CRLF_LEN;	/* headers*/	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )		switch (hdr->type)		{			case HDR_TO:				if (new_tag){					if (to_tag.s ) {						append_str_trans( p, hdr->name.s ,							to_tag.s-hdr->name.s,msg);						append_str( p, new_tag,new_tag_len,msg);						append_str_trans( p,to_tag.s+to_tag.len,							((hdr->body.s+hdr->body.len )-							(to_tag.s+to_tag.len)),msg);						append_str( p, CRLF,CRLF_LEN,msg);					}else{						append_str_trans( p, hdr->name.s ,							((hdr->body.s+hdr->body.len )-hdr->name.s ),							msg);						append_str( p, TOTAG_TOKEN,TOTAG_TOKEN_LEN,msg);						append_str( p, new_tag,new_tag_len,msg);						append_str( p, CRLF,CRLF_LEN,msg);					}					break;				}			case HDR_VIA:				append_str_trans( p, hdr->name.s ,					((hdr->body.s+hdr->body.len )-hdr->name.s ),msg);				if (hdr==msg->h_via1 && received_buf)					append_str( p, received_buf, received_len, msg);				append_str( p, CRLF,CRLF_LEN,msg);				break;			case HDR_RECORDROUTE:				/* RR only for 1xx and 2xx replies */				if (code<180 || code>=300) break;			case HDR_FROM:			case HDR_CALLID:			case HDR_CSEQ:					append_str_trans( p, hdr->name.s ,						((hdr->body.s+hdr->body.len )-hdr->name.s ),msg);					append_str( p, CRLF,CRLF_LEN,msg);		} /* for switch */	/*lumps*/	for(lump=msg->reply_lump;lump;lump=lump->next)	{		memcpy(p,lump->text.s,lump->text.len);		p += lump->text.len;	}	if (server_signature) {		/*server header*/		memcpy( p, SERVER_HDR , SERVER_HDR_LEN );		p+=SERVER_HDR_LEN;		memcpy( p, CRLF, CRLF_LEN );		p+=CRLF_LEN;		/* content length header*/		memcpy( p, CONTENT_LENGTH "0" , CONTENT_LENGTH_LEN+1 );		p+=CONTENT_LENGTH_LEN+1;		memcpy( p, CRLF, CRLF_LEN );		p+=CRLF_LEN;	}	if (sip_warning) {		memcpy( p, warning, warning_len);		p+=warning_len;		memcpy( p, CRLF, CRLF_LEN);		p+=CRLF_LEN;	}	/*end of message*/	memcpy( p, CRLF, CRLF_LEN );	p+=CRLF_LEN;	*(p) = 0;	*returned_len = len;	/* in req2reply, received_buf is not introduced to lumps and	   needs to be deleted here	*/	if (received_buf) pkg_free(received_buf);	return buf;error01:	if (received_buf) pkg_free(received_buf);error00:	*returned_len=0;	return 0;}