<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13598">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_sip.c: Stop handling continuation lines after reading headers<br><br>lws2sws() does not stop trying to handle header continuation lines<br>even after all headers have been found. This is problematic if the<br>first character of a SIP message body is a space or tab character, so<br>we update to recognize the end of the message header.<br><br>ASTERISK-28693 #close<br>Reported by: Frank Matano<br><br>Change-Id: Idec8fa58545cd3fd898cbe0075d76c223f8d33df<br>---<br>M channels/chan_sip.c<br>1 file changed, 15 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/98/13598/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index f90d3f9..9de211e 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -9833,8 +9833,10 @@</span><br><span> int len = ast_str_strlen(data);</span><br><span> int h = 0, t = 0;</span><br><span> int lws = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int just_read_eol = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int done_with_headers = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- for (; h < len;) {</span><br><span style="color: hsl(120, 100%, 40%);">+ while (h < len) {</span><br><span> /* Eliminate all CRs */</span><br><span> if (msgbuf[h] == '\r') {</span><br><span> h++;</span><br><span>@@ -9842,11 +9844,18 @@</span><br><span> }</span><br><span> /* Check for end-of-line */</span><br><span> if (msgbuf[h] == '\n') {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (just_read_eol) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "HERE\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ done_with_headers = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ just_read_eol = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> /* Check for end-of-message */</span><br><span> if (h + 1 == len)</span><br><span> break;</span><br><span> /* Check for a continuation line */</span><br><span style="color: hsl(0, 100%, 40%);">- if (msgbuf[h + 1] == ' ' || msgbuf[h + 1] == '\t') {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!done_with_headers</span><br><span style="color: hsl(120, 100%, 40%);">+ && (msgbuf[h + 1] == ' ' || msgbuf[h + 1] == '\t')) {</span><br><span> /* Merge continuation line */</span><br><span> h++;</span><br><span> continue;</span><br><span>@@ -9855,8 +9864,11 @@</span><br><span> msgbuf[t++] = msgbuf[h++];</span><br><span> lws = 0;</span><br><span> continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ just_read_eol = 0;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (msgbuf[h] == ' ' || msgbuf[h] == '\t') {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!done_with_headers</span><br><span style="color: hsl(120, 100%, 40%);">+ && (msgbuf[h] == ' ' || msgbuf[h] == '\t')) {</span><br><span> if (lws) {</span><br><span> h++;</span><br><span> continue;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13598">change 13598</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13598"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Idec8fa58545cd3fd898cbe0075d76c223f8d33df </div>
<div style="display:none"> Gerrit-Change-Number: 13598 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>