<p>Nick French has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9483">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Remove spurious error logging when printing silent headers<br><br>Asterisk patched the pjproject source to avoid crashing when pjproject<br>sip_msg headers are encountered with NULL vptr's, but the patch also<br>output error messages for some valid headers which simply did not need<br>to be added to the message itself, such as hidden route headers.<br><br>pjproject has since applied a similar patch to their baseline to avoid<br>crashes, but their version also avoids the spurious error logging.<br><br>Lets use their patch instead.<br><br>ASTERISK-27961 #close<br><br>Change-Id: I2ddbd82c8da10e0dcc9807a48089d1f3c2d6e389<br>---<br>M third-party/pjproject/patches/0060-sip_msg-Prevent-crash-on-header-without-vptr.patch<br>1 file changed, 21 insertions(+), 32 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/9483/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0060-sip_msg-Prevent-crash-on-header-without-vptr.patch b/third-party/pjproject/patches/0060-sip_msg-Prevent-crash-on-header-without-vptr.patch</span><br><span>index c96292a..1ffa301 100644</span><br><span>--- a/third-party/pjproject/patches/0060-sip_msg-Prevent-crash-on-header-without-vptr.patch</span><br><span>+++ b/third-party/pjproject/patches/0060-sip_msg-Prevent-crash-on-header-without-vptr.patch</span><br><span>@@ -1,20 +1,7 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From cf6b662b8fe450ea7dc6eb5adb2b878971ce0d67 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Wed, 10 Jan 2018 08:48:32 -0700</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH] sip_msg: Prevent crash on header without vptr</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-Occasionally a header with no vptr gets into the list of header. This</span><br><span style="color: hsl(0, 100%, 40%);">-causes a crash when printing them. We still need to figure out how</span><br><span style="color: hsl(0, 100%, 40%);">-the header got there but this patch at least prevents the crash by checking</span><br><span style="color: hsl(0, 100%, 40%);">-for a non-NULL vptr before attempting to call its print function.</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_msg.c | 6 ++++++</span><br><span style="color: hsl(0, 100%, 40%);">- 1 file changed, 6 insertions(+)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip/sip_msg.c b/pjsip/src/pjsip/sip_msg.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 76d07b563..194b5ee01 100644</span><br><span>---- a/pjsip/src/pjsip/sip_msg.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_msg.c</span><br><span style="color: hsl(120, 100%, 40%);">+Index: trunk/pjsip/src/pjsip/sip_msg.c</span><br><span style="color: hsl(120, 100%, 40%);">+===================================================================</span><br><span style="color: hsl(120, 100%, 40%);">+--- trunk/pjsip/src/pjsip/sip_msg.c (revision 5726)</span><br><span>++++ trunk/pjsip/src/pjsip/sip_msg.c (revision 5727)</span><br><span> @@ -26,6 +26,7 @@</span><br><span> #include <pj/string.h></span><br><span> #include <pj/pool.h></span><br><span>@@ -23,25 +10,27 @@</span><br><span> #include <pjlib-util/string.h></span><br><span> </span><br><span> PJ_DEF_DATA(const pjsip_method) pjsip_invite_method =</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -469,6 +470,8 @@ PJ_DEF(pj_ssize_t) pjsip_msg_print( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -459,8 +460,13 @@</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Print each of the headers. */</span><br><span style="color: hsl(120, 100%, 40%);">+ for (hdr=msg->hdr.next; hdr!=&msg->hdr; hdr=hdr->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ len = pjsip_hdr_print_on(hdr, p, end-p);</span><br><span style="color: hsl(120, 100%, 40%);">+- if (len < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+- return -1;</span><br><span style="color: hsl(120, 100%, 40%);">++ if (len < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">++ if (len == -2) {</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_LOG(5, ("sip_msg", "Header with no vptr encountered!! "\</span><br><span style="color: hsl(120, 100%, 40%);">++ "Current buffer: %.*s", (int)(p-buf), buf));</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">++ return len;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- *p++ = '\r';</span><br><span style="color: hsl(0, 100%, 40%);">- *p++ = '\n';</span><br><span style="color: hsl(0, 100%, 40%);">-+ } else {</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_LOG(1, ("sip_msg", "Header with no vptr encountered!! Current buffer: %.*s", (int)(p-buf), buf));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -576,6 +579,9 @@ PJ_DEF(void*) pjsip_hdr_shallow_clone( pj_pool_t *pool, const void *hdr_ptr )</span><br><span style="color: hsl(120, 100%, 40%);">+ if (len > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ p += len;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -576,6 +582,7 @@</span><br><span> PJ_DEF(int) pjsip_hdr_print_on( void *hdr_ptr, char *buf, pj_size_t len)</span><br><span> {</span><br><span> pjsip_hdr *hdr = (pjsip_hdr*) hdr_ptr;</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (!hdr->vptr) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ return 0;</span><br><span style="color: hsl(0, 100%, 40%);">-+ }</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_ASSERT_RETURN(hdr->vptr, -2);</span><br><span> return (*hdr->vptr->print_on)(hdr_ptr, buf, len);</span><br><span> }</span><br><span> </span><br><span>--- </span><br><span style="color: hsl(0, 100%, 40%);">-2.14.3</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9483">change 9483</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/9483"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2ddbd82c8da10e0dcc9807a48089d1f3c2d6e389 </div>
<div style="display:none"> Gerrit-Change-Number: 9483 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nick French <naf@ou.edu> </div>