From: <cha...@us...> - 2008-09-25 14:27:17
|
Revision: 541 http://sipp.svn.sourceforge.net/sipp/?rev=541&view=rev Author: charlespwright Date: 2008-09-25 14:27:13 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Fix: Correct problems with NUL message handling corrupting authenticated messages. Modified Paths: -------------- sipp/trunk/call.cpp sipp/trunk/message.cpp Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2008-09-25 11:50:51 UTC (rev 540) +++ sipp/trunk/call.cpp 2008-09-25 14:27:13 UTC (rev 541) @@ -1195,6 +1195,7 @@ static char msg_name[MAX_MSG_NAME_SIZE]; char *L_ptr1 ; char *L_ptr2 ; + int uselen = 0; assert(send_status); @@ -1213,6 +1214,10 @@ assert(call_scenario->messages[index]->send_scheme); + if (!len) { + len = &uselen; + } + char * dest; dest = createSendingMessage(call_scenario->messages[index] -> send_scheme, index, len); @@ -2382,7 +2387,7 @@ if (body && dest - body > 4 && dest - body < 100004) { char tmp = length_marker[5]; - sprintf(length_marker, "%5u", dest - body - 4 + len_offset); + sprintf(length_marker, "%5u", (unsigned)(dest - body - 4 + len_offset)); length_marker[5] = tmp; } else { // Other cases: Content-Length is 0 @@ -2390,6 +2395,10 @@ } } + if (msgLen) { + *msgLen = dest - msg_buffer; + } + /* * The authentication substitution must be done outside the above * loop because auth-int will use the body (which must have already @@ -2459,6 +2468,9 @@ memmove(auth_marker + authlen, auth_marker + auth_marker_len, strlen(auth_marker + auth_marker_len) + 1); /* Copy our result into the hole. */ memcpy(auth_marker, result, authlen); + if (msgLen) { + *msgLen += (authlen - auth_marker_len); + } #endif } @@ -2466,10 +2478,6 @@ SendingMessage::freeMessageComponent(auth_comp); } - if (msgLen != NULL) { - *msgLen = dest - msg_buffer; - } - return msg_buffer; } Modified: sipp/trunk/message.cpp =================================================================== --- sipp/trunk/message.cpp 2008-09-25 11:50:51 UTC (rev 540) +++ sipp/trunk/message.cpp 2008-09-25 14:27:13 UTC (rev 541) @@ -137,7 +137,7 @@ literalLen = dest - literal; if (literalLen) { *dest = '\0'; - literal = (char *)realloc(literal, literalLen); + literal = (char *)realloc(literal, literalLen + 1); if (!literal) { ERROR("Out of memory!"); } MessageComponent *newcomp = (MessageComponent *)calloc(1, sizeof(MessageComponent)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |