Ver código fonte

- another bug fixed (wrong new_len in forward_reply)

Andrei Pelinescu-Onciul 24 anos atrás
pai
commit
413d69f15a
2 arquivos alterados com 12 adições e 3 exclusões
  1. 11 2
      forward.c
  2. 1 1
      sip_router.cfg

+ 11 - 2
forward.c

@@ -196,23 +196,32 @@ int forward_reply(char * orig, char* buf,
 	/* we must remove the first via */
 	/* we must remove the first via */
 	via_len=msg->via1.size;
 	via_len=msg->via1.size;
 	size=msg->via1.hdr-buf;
 	size=msg->via1.hdr-buf;
+	printf("via len: %d, initial size: %d\n", via_len, size);
 	if (msg->via1.next){
 	if (msg->via1.next){
 		/* keep hdr =substract hdr size +1 (hdr':') and add
 		/* keep hdr =substract hdr size +1 (hdr':') and add
 		 */
 		 */
 		via_len-=strlen(msg->via1.hdr)+1;
 		via_len-=strlen(msg->via1.hdr)+1;
 		size+=strlen(msg->via1.hdr)+1;
 		size+=strlen(msg->via1.hdr)+1;
+	    printf(" adjusted via len: %d, initial size: %d\n",
+				via_len, size);
 	}
 	}
-	new_len=len-size;
-	new_buf=(char*)malloc(new_len);
+	new_len=len-via_len;
+	
+	printf(" old size: %d, new size: %d\n", len, new_len);
+	new_buf=(char*)malloc(new_len+1);/* +1 is for debugging (\0 to print it )*/
 	if (new_buf==0){
 	if (new_buf==0){
 		DPrint("ERROR: forward_reply: out of memory\n");
 		DPrint("ERROR: forward_reply: out of memory\n");
 		goto error;
 		goto error;
 	}
 	}
+	new_buf[new_len]=0; /* debug: print the message */
 	memcpy(new_buf, orig, size);
 	memcpy(new_buf, orig, size);
 	offset=size;
 	offset=size;
 	s_offset=size+via_len;
 	s_offset=size+via_len;
 	memcpy(new_buf+offset,orig+s_offset, len-s_offset);
 	memcpy(new_buf+offset,orig+s_offset, len-s_offset);
 	 /* send it! */
 	 /* send it! */
+	printf(" copied size: orig:%d, new: %d, rest: %d\n",
+			s_offset, offset, 
+			len-s_offset );
 	printf("Sending: to %s:%d, \n%s.\n",
 	printf("Sending: to %s:%d, \n%s.\n",
 			msg->via2.host, 
 			msg->via2.host, 
 			(unsigned short)msg->via2.port,
 			(unsigned short)msg->via2.port,

+ 1 - 1
sip_router.cfg

@@ -5,7 +5,7 @@
 # (warning: re cannot contain space)
 # (warning: re cannot contain space)
 
 
 #.			.				   centauri
 #.			.				   centauri
-#.*			.*				   mobile50 
+.*			.*				   mobile50 
 .			.				   fox.iptel.org
 .			.				   fox.iptel.org
 ^R.*        ^sip:.*@dorian.*   ekina.fokus.gmd.de        
 ^R.*        ^sip:.*@dorian.*   ekina.fokus.gmd.de        
 ^INVITE     .*                 ape:5061             # my laptop
 ^INVITE     .*                 ape:5061             # my laptop