[Asterisk-code-review] res pjsip: Remove spurious error logging when printing sile... (asterisk[13])

Nick French asteriskteam at digium.com
Tue Jul 17 09:10:23 CDT 2018


Nick French has uploaded this change for review. ( https://gerrit.asterisk.org/9483


Change subject: res_pjsip:  Remove spurious error logging when printing silent headers
......................................................................

res_pjsip:  Remove spurious error logging when printing silent headers

Asterisk patched the pjproject source to avoid crashing when pjproject
sip_msg headers are encountered with NULL vptr's, but the patch also
output error messages for some valid headers which simply did not need
to be added to the message itself, such as hidden route headers.

pjproject has since applied a similar patch to their baseline to avoid
crashes, but their version also avoids the spurious error logging.

Lets use their patch instead.

ASTERISK-27961 #close

Change-Id: I2ddbd82c8da10e0dcc9807a48089d1f3c2d6e389
---
M third-party/pjproject/patches/0060-sip_msg-Prevent-crash-on-header-without-vptr.patch
1 file changed, 21 insertions(+), 32 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/9483/1

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
index c96292a..1ffa301 100644
--- 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
@@ -1,20 +1,7 @@
-From cf6b662b8fe450ea7dc6eb5adb2b878971ce0d67 Mon Sep 17 00:00:00 2001
-From: George Joseph <gjoseph at digium.com>
-Date: Wed, 10 Jan 2018 08:48:32 -0700
-Subject: [PATCH] sip_msg: Prevent crash on header without vptr
-
-Occasionally a header with no vptr gets into the list of header.  This
-causes a crash when printing them.  We still need to figure out how
-the header got there but this patch at least prevents the crash by checking
-for a non-NULL vptr before attempting to call its print function.
----
- pjsip/src/pjsip/sip_msg.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/pjsip/src/pjsip/sip_msg.c b/pjsip/src/pjsip/sip_msg.c
-index 76d07b563..194b5ee01 100644
---- a/pjsip/src/pjsip/sip_msg.c
-+++ b/pjsip/src/pjsip/sip_msg.c
+Index: trunk/pjsip/src/pjsip/sip_msg.c
+===================================================================
+--- trunk/pjsip/src/pjsip/sip_msg.c	(revision 5726)
++++ trunk/pjsip/src/pjsip/sip_msg.c	(revision 5727)
 @@ -26,6 +26,7 @@
  #include <pj/string.h>
  #include <pj/pool.h>
@@ -23,25 +10,27 @@
  #include <pjlib-util/string.h>
  
  PJ_DEF_DATA(const pjsip_method) pjsip_invite_method =
-@@ -469,6 +470,8 @@ PJ_DEF(pj_ssize_t) pjsip_msg_print( const pjsip_msg *msg,
+@@ -459,8 +460,13 @@
+     /* Print each of the headers. */
+     for (hdr=msg->hdr.next; hdr!=&msg->hdr; hdr=hdr->next) {
+ 	len = pjsip_hdr_print_on(hdr, p, end-p);
+-	if (len < 0)
+-	    return -1;
++	if (len < 0) {
++	   if (len == -2) {
++	       PJ_LOG(5, ("sip_msg", "Header with no vptr encountered!! "\
++			  "Current buffer: %.*s", (int)(p-buf), buf));
++	   }
++	   return len;
++	}
  
- 	    *p++ = '\r';
- 	    *p++ = '\n';
-+	} else {
-+	    PJ_LOG(1, ("sip_msg", "Header with no vptr encountered!!  Current buffer: %.*s", (int)(p-buf), buf));
- 	}
-     }
- 
-@@ -576,6 +579,9 @@ PJ_DEF(void*) pjsip_hdr_shallow_clone( pj_pool_t *pool, const void *hdr_ptr )
+ 	if (len > 0) {
+ 	    p += len;
+@@ -576,6 +582,7 @@
  PJ_DEF(int) pjsip_hdr_print_on( void *hdr_ptr, char *buf, pj_size_t len)
  {
      pjsip_hdr *hdr = (pjsip_hdr*) hdr_ptr;
-+    if (!hdr->vptr) {
-+        return 0;
-+    }
++    PJ_ASSERT_RETURN(hdr->vptr, -2);
      return (*hdr->vptr->print_on)(hdr_ptr, buf, len);
  }
  
--- 
-2.14.3
-

-- 
To view, visit https://gerrit.asterisk.org/9483
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ddbd82c8da10e0dcc9807a48089d1f3c2d6e389
Gerrit-Change-Number: 9483
Gerrit-PatchSet: 1
Gerrit-Owner: Nick French <naf at ou.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180717/4ba11725/attachment-0001.html>


More information about the asterisk-code-review mailing list