Browse code

- another bug fixed (wrong new_len in forward_reply)

Andrei Pelinescu-Onciul authored on 06/09/2001 19:14:19
Showing 2 changed files
... ...
@@ -196,23 +196,32 @@ int forward_reply(char * orig, char* buf,
196 196
 	/* we must remove the first via */
197 197
 	via_len=msg->via1.size;
198 198
 	size=msg->via1.hdr-buf;
199
+	printf("via len: %d, initial size: %d\n", via_len, size);
199 200
 	if (msg->via1.next){
200 201
 		/* keep hdr =substract hdr size +1 (hdr':') and add
201 202
 		 */
202 203
 		via_len-=strlen(msg->via1.hdr)+1;
203 204
 		size+=strlen(msg->via1.hdr)+1;
205
+	    printf(" adjusted via len: %d, initial size: %d\n",
206
+				via_len, size);
204 207
 	}
205
-	new_len=len-size;
206
-	new_buf=(char*)malloc(new_len);
208
+	new_len=len-via_len;
209
+	
210
+	printf(" old size: %d, new size: %d\n", len, new_len);
211
+	new_buf=(char*)malloc(new_len+1);/* +1 is for debugging (\0 to print it )*/
207 212
 	if (new_buf==0){
208 213
 		DPrint("ERROR: forward_reply: out of memory\n");
209 214
 		goto error;
210 215
 	}
216
+	new_buf[new_len]=0; /* debug: print the message */
211 217
 	memcpy(new_buf, orig, size);
212 218
 	offset=size;
213 219
 	s_offset=size+via_len;
214 220
 	memcpy(new_buf+offset,orig+s_offset, len-s_offset);
215 221
 	 /* send it! */
222
+	printf(" copied size: orig:%d, new: %d, rest: %d\n",
223
+			s_offset, offset, 
224
+			len-s_offset );
216 225
 	printf("Sending: to %s:%d, \n%s.\n",
217 226
 			msg->via2.host, 
218 227
 			(unsigned short)msg->via2.port,
... ...
@@ -5,7 +5,7 @@
5 5
 # (warning: re cannot contain space)
6 6
 
7 7
 #.			.				   centauri
8
-#.*			.*				   mobile50 
8
+.*			.*				   mobile50 
9 9
 .			.				   fox.iptel.org
10 10
 ^R.*        ^sip:.*@dorian.*   ekina.fokus.gmd.de        
11 11
 ^INVITE     .*                 ape:5061             # my laptop