Hi,

While checking my app with valgrind, I stumblet upon this:

==32322== Invalid read of size 1
==32322==    at 0x4530928: parse_headers(sip_msg*, char**) 
(parse_header.cpp:289)
==32322==    by 0x453F987: parse_sip_msg(sip_msg*) (sip_parser.cpp:409)
==32322==    by 0x454708D: trans_layer::send_request(sip_msg*, char*, 
unsigned&) (trans_la
yer.cpp:548)
==32322==    by 0x45364FD: SipCtrlInterface::send(AmSipRequest const&, char*, 
unsigned&) (
SipCtrlInterface.cpp:322)

looks like parse header expects a nullterminated string, but the trans_layer 
doesn't give it one, the patch below fixes it. I hope it's correct :)

br

Szo
Index: trans_layer.cpp
===================================================================
--- trans_layer.cpp	(revision 343)
+++ trans_layer.cpp	(working copy)
@@ -521,7 +521,7 @@
 
     // Allocate new message
     sip_msg* p_msg = new sip_msg();
-    p_msg->buf = new char[request_len];
+    p_msg->buf = new char[request_len+1];
     p_msg->len = request_len;
 
     // generate it
@@ -540,9 +540,9 @@
     if(msg->body.len){
 	memcpy(c,msg->body.s,msg->body.len);
 
-	// Not needed by now as the message is finished
-	//c += body.len;
+	c += msg->body.len;
     }
+    *c++ = '\0';
 
     // and parse it
     if(parse_sip_msg(p_msg)){
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to