Commit d2025a63 authored by jehan's avatar jehan

fix for: 0001084: Parser expects non-empty reason phrase in status line

parent 7d18e343
......@@ -145,7 +145,7 @@ belle_sip_error_code belle_http_response_marshal(belle_http_response_t *resp, ch
,offset
,"HTTP/1.1 %i %s\r\n"
,belle_http_response_get_status_code(resp)
,belle_http_response_get_reason_phrase(resp));
,belle_http_response_get_reason_phrase(resp)?belle_http_response_get_reason_phrase(resp):"");
if (error!=BELLE_SIP_OK) return error;
error=belle_sip_headers_marshal(BELLE_SIP_MESSAGE(resp),buff,buff_size,offset);
if (error!=BELLE_SIP_OK) return error;
......
......@@ -544,7 +544,7 @@ belle_sip_error_code belle_sip_response_marshal(belle_sip_response_t *resp, char
,offset
,"SIP/2.0 %i %s\r\n"
,belle_sip_response_get_status_code(resp)
,belle_sip_response_get_reason_phrase(resp));
,belle_sip_response_get_reason_phrase(resp)?belle_sip_response_get_reason_phrase(resp):"");
if (error!=BELLE_SIP_OK) return error;
error=belle_sip_headers_marshal(BELLE_SIP_MESSAGE(resp),buff,buff_size,offset);
if (error!=BELLE_SIP_OK) return error;
......
......@@ -144,6 +144,30 @@ static void test401Response(void) {
belle_sip_free(encoded_message);
}
static void test401ResponseWithoutResponsePhrase(void) {
const char* raw_message = "SIP/2.0 401 \r\n"
"Call-ID: 577586163\r\n"
"CSeq: 21 REGISTER\r\n"
"From: <sip:0033532176@sip.ovh.net>;tag=1790643209\r\n"
"Server: Cirpack/v4.42x (gw_sip)\r\n"
"To: <sip:0033482176@sip.ovh.net>;tag=00-08075-24212984-22e348d97\r\n"
"Via: SIP/2.0/UDP 192.168.0.18:5062;received=81.56.113.2;rport=5062;branch=z9hG4bK1939354046\r\n"
"WWW-Authenticate: Digest realm=\"sip.ovh.net\",nonce=\"24212965507cde726e8bc37e04686459\",opaque=\"241b9fb347752f2\",stale=false,algorithm=MD5\r\n"
"Content-Length: 0\r\n\r\n";
belle_sip_response_t* response;
belle_sip_message_t* message = belle_sip_message_parse(raw_message);
char* encoded_message = belle_sip_object_to_string(BELLE_SIP_OBJECT(message));
belle_sip_object_unref(BELLE_SIP_OBJECT(message));
message = belle_sip_message_parse(encoded_message);
response = BELLE_SIP_RESPONSE(message);
CU_ASSERT_EQUAL(belle_sip_response_get_status_code(response),401);
CU_ASSERT_PTR_NULL(belle_sip_response_get_reason_phrase(response));
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"WWW-Authenticate"));
check_uri_and_headers(message);
belle_sip_object_unref(message);
belle_sip_free(encoded_message);
}
static void testRegisterRaw(void) {
const char* raw_message = "REGISTER sip:192.168.0.20 SIP/2.0\r\n"\
"Via: SIP/2.0/UDP 192.168.1.8:5062;rport;branch=z9hG4bK1439638806\r\n"\
......@@ -726,6 +750,7 @@ test_t message_tests[] = {
{ "Option message", testOptionMessage },
{ "REGISTER (Raw)", testRegisterRaw },
{ "401 Response", test401Response },
{ "Response without response phrase",test401ResponseWithoutResponsePhrase},
{ "Origin extraction", test_extract_source },
{ "SIP frag", test_sipfrag },
{ "Malformed invite", testMalformedMessage },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment