Browse code

fixed zero termination bug in received_builder

Nils Ohlmeier authored on 24/01/2003 17:29:20
Showing 1 changed files
... ...
@@ -197,7 +197,7 @@ char* received_builder(struct sip_msg *msg, unsigned int *received_len)
197 197
 	if ( (tmp=ip_addr2a(source_ip))==0)
198 198
 		return 0; /* error*/
199 199
 	tmp_len=strlen(tmp);
200
-	len=RECEIVED_LEN+tmp_len+1; /* space for  null termination */
200
+	len=RECEIVED_LEN+tmp_len;
201 201
 	if(source_ip->af==AF_INET6){
202 202
 		len+=2;
203 203
 		buf[RECEIVED_LEN]='[';
... ...
@@ -206,7 +206,7 @@ char* received_builder(struct sip_msg *msg, unsigned int *received_len)
206 206
 	}
207 207
 	
208 208
 	memcpy(buf+RECEIVED_LEN+extra_len, tmp, tmp_len);
209
-	buf[len]=0; /*null terminate it */
209
+	buf[len+1]=0; /*null terminate it */
210 210
 
211 211
 	*received_len = len;
212 212
 	return buf;