Skip to content

Crash when passing non-string header value to add_headers #123

@MayamaTakeshi

Description

@MayamaTakeshi

If we try this:

    var oc = sip.call.create(gw1_t.id, {
        from_uri: `"${caller}"<sip:${caller}@test.com>`,
        to_uri: `sip:${prefix}${callee}@${c.server_ip1}`,
        headers: {
           'X-MyHeader1': 'abc',
           'X-MyHeader2': 'def',
           'Max-Forwards': 20,
        },
    })

sip-lab will segfault like this:

json_get_string_param from_uri
json_get_string_param to_uri
json_get_string_param request_uri
json_get_string_param proxy_uri
process_media call_id=0
i=0 media not found

create_media_endpoint call_id=0
create_media_transport
med_endtp->port=10000
create_media_endpoint call_id=0 type=1
i=0 media created 0x3aab9220

process_media call_id=0 call->local_sdp: v=0
o=- 3962149935 3962149935 IN IP4 0.0.0.0
s=pjmedia
t=0 0
m=audio 10000 RTP/AVP 0 8 3 120
c=IN IP4 127.0.0.1
b=TIAS:64000
a=rtcp:10001 IN IP4 127.0.0.1
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:120 telephone-event/8000
a=fmtp:120 0-16


X-MyHeader1 => 'abc'
X-MyHeader2 => 'def'
close_media call_id=0
close_media_endpoint 0x3aab9220
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
audio_endpoint_remove_port
success
close_media_transport 0x3aab9e78
node: ../src/pjsip/sip_dialog.c:879: pjsip_dlg_terminate: Assertion `dlg->sess_count==0' failed.
Aborted (core dumped)
takeshi@takeshi-desktop:sip-lab$

Notice that it stopped before printing header Max-Forwards, so it is likely it properly detected Max-Forwards value is not a string and set_error and exited.
But then when performing the clean up of the media endpoint, it crashed and so we didn't see the error message as I think it would have been printed later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions