<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13638">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><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, 14 insertions(+), 3 deletions(-)<br><br></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 580954a..789e3d7 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -9869,8 +9869,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>@@ -9878,11 +9880,17 @@</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%);">+                          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>@@ -9891,8 +9899,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/+/13638">change 13638</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/+/13638"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Idec8fa58545cd3fd898cbe0075d76c223f8d33df </div>
<div style="display:none"> Gerrit-Change-Number: 13638 </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-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>