[Home]

Summary:ASTERISK-28693: chan_sip: SIP MESSAGE beginning with a whitespace appears empty in the dialplan
Reporter:Frank Matano (Derivative)Labels:
Date Opened:2020-01-15 07:26:35.000-0600Date Closed:2020-01-21 08:21:21.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:Channels/chan_sip/Messaging
Versions:16.2.1 Frequency of
Occurrence
Constant
Related
Issues:
duplicatesASTERISK-26461 chan_sip: SIP MESSAGE body parsed incorrectly (as headers) if first character is a space (0x20)
Environment:Linux debian 4.19.0-6-686-pae #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) i686 GNU/Linux Attachments:( 0) out.cap
Description:User agent Baresip v0.6.5 is sending a valid MESSAGE:
{noformat}
MESSAGE sip:mist@eee SIP/2.0
Via: SIP/2.0/UDP 192.168.4.18:5566;branch=z9hG4bK0d16bdb32c8c518a;rport
Max-Forwards: 70
To: <sip:mist@eee>
From: <sip:eee@eee>;tag=bdafebcf5b867c48
Call-ID: 689603aa8194865a
CSeq: 13255 MESSAGE
User-Agent: baresip v0.6.5 (?/?)
Accept: text/plain
Content-Type: text/plain
Content-Length: 3

ii
{noformat}

(the {{" ii"}} message begins with a whitespace)

Asterisk sip.conf:
{noformat}
[general]
context=incoming
accept_outofcall_message=yes
outofcall_message_context=iimm
{noformat}

Dialplan:
{noformat}
[iimm]
exten => _[a-z].,1,NoOp('${MESSAGE(body)}')
exten => _[a-z].,n,Hangup()
{noformat}
Result:
{noformat}
-- Executing [mist@iimm:1] NoOp("Message/ast_msg_queue", "''") in new stack
{noformat}

Sending the same message " ii" to another Baresip client without Asterisk as a proxy works fine.
Comments:By: Asterisk Team (asteriskteam) 2020-01-15 07:26:36.231-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Sean Bright (seanbright) 2020-01-15 10:15:42.239-0600

[~Derivative] - Unless there is a blank line after the {{Content-Length}} header and before the {{<sp>ii}}, then it is not a valid SIP message. Did you just paste it wrong?

By: Frank Matano (Derivative) 2020-01-15 17:31:23.718-0600

True. When prepending a whitespace, Baresip user agent output is the one I have (correctly) pasted above. When whitespace is not present the output is:
{noformat}
<--- SIP read from UDP:192.168.4.18:5566 --->
MESSAGE sip:mist@eee SIP/2.0
Via: SIP/2.0/UDP 192.168.4.18:5566;branch=z9hG4bK10eca9dd85f2796c;rport
Max-Forwards: 70
To: <sip:mist@eee>
From: <sip:eee@eee>;tag=88fc6d67f52515f1
Call-ID: 20f44be1a3a8f536
CSeq: 50301 MESSAGE
User-Agent: baresip v0.6.5 (?/?)
Accept: text/plain
Content-Type: text/plain
Content-Length: 4

test
<------------->
{noformat}

By: Sean Bright (seanbright) 2020-01-15 17:34:23.424-0600

[~Derivative], then that would indicate a bug in [baresip|https://github.com/alfredh/baresip], unless I don't understand?

By: Sean Bright (seanbright) 2020-01-15 17:46:11.012-0600

[~Derivative] - rather than capturing and attaching the SIP debug output from Asterisk, could you use wireshark or tcpdump to capture the SIP traffic and attach that to this issue? I want to confirm that what Asterisk is displaying is what is actually being sent to it. If you could capture an example of both message types - one that starts with a space and one that does not - that would be really helpful.

By: Frank Matano (Derivative) 2020-01-16 03:09:07.636-0600

Of course, here's the .cap file of the traffic exchanged between client and server captured with {noformat} tcpdump -i wlan0 -w out.cap port 5060{noformat}
During capture I've sent two messages to the same recipient. First message is "no whitespace", the second is " with whitespace".

By: Joshua C. Colp (jcolp) 2020-01-16 05:28:01.886-0600

I just tested PJSIP to see if it was impacted and it clears out whitespace at the front and back leaving the rest of the message.

By: Frank Matano (Derivative) 2020-01-16 09:13:50.629-0600

Hello sirs. Unfortunately migrating to PJSIP is not an option. If you confirm Asterisk is parsing MESSAGE correctly I'll open an issue on Baresip Github repo. Thank you very much.

By: Sean Bright (seanbright) 2020-01-16 09:17:46.705-0600

Nope, it's a bug in {{chan_sip}}. I have a review up to address it.

By: Friendly Automation (friendly-automation) 2020-01-21 08:21:22.231-0600

Change 13598 merged by Friendly Automation:
chan_sip.c: Stop handling continuation lines after reading headers

[https://gerrit.asterisk.org/c/asterisk/+/13598|https://gerrit.asterisk.org/c/asterisk/+/13598]

By: Friendly Automation (friendly-automation) 2020-01-21 08:26:14.715-0600

Change 13640 merged by Friendly Automation:
chan_sip.c: Stop handling continuation lines after reading headers

[https://gerrit.asterisk.org/c/asterisk/+/13640|https://gerrit.asterisk.org/c/asterisk/+/13640]

By: Friendly Automation (friendly-automation) 2020-01-21 08:26:34.128-0600

Change 13639 merged by Friendly Automation:
chan_sip.c: Stop handling continuation lines after reading headers

[https://gerrit.asterisk.org/c/asterisk/+/13639|https://gerrit.asterisk.org/c/asterisk/+/13639]

By: Friendly Automation (friendly-automation) 2020-01-21 08:28:26.413-0600

Change 13638 merged by Friendly Automation:
chan_sip.c: Stop handling continuation lines after reading headers

[https://gerrit.asterisk.org/c/asterisk/+/13638|https://gerrit.asterisk.org/c/asterisk/+/13638]

By: Thomas Guebels (tguescaux) 2021-10-26 10:56:16.080-0500

Isn't this fixing ASTERISK-26461 ?