[Asterisk-code-review] res pjsip/res pjsip callerid: NULL check on caller id name s... (asterisk[14])

Kevin Harwell asteriskteam at digium.com
Wed Apr 26 14:26:05 CDT 2017


Kevin Harwell has uploaded a new change for review. ( https://gerrit.asterisk.org/5542 )

Change subject: res_pjsip/res_pjsip_callerid: NULL check on caller id name string
......................................................................

res_pjsip/res_pjsip_callerid: NULL check on caller id name string

It's possible for a name in a party id structure to be marked as valid, but the
name string itself be NULL. There were a couple of places where the name was
validated, but the string itself was not checked before passing it to functions
like 'strlen'. This of course caused a crashed.

This patch adds in a NULL check before attempting to pass it into a function
that is not NULL tolerant.

ASTERISK-25823 #close

Change-Id: Iaa6ffe9d92f598fe9e3c8ae373fadbe3dfbf1d4a
---
M res/res_pjsip.c
M res/res_pjsip_caller_id.c
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/5542/1

diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 340ba87..c0455f6 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -4413,7 +4413,7 @@
 	id_name_addr = (pjsip_name_addr *) id_hdr->uri;
 	id_uri = pjsip_uri_get_uri(id_name_addr->uri);
 
-	if (id->name.valid) {
+	if (id->name.valid && !ast_strlen_zero(id->name.str)) {
 		int name_buf_len = strlen(id->name.str) * 2 + 1;
 		char *name_buf = ast_alloca(name_buf_len);
 
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 7948d33..976cf3a 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -436,7 +436,7 @@
 	id_name_addr = pjsip_uri_clone(tdata->pool, base->uri);
 	id_uri = pjsip_uri_get_uri(id_name_addr->uri);
 
-	if (id->name.valid) {
+	if (id->name.valid && !ast_strlen_zero(id->name.str)) {
 		int name_buf_len = strlen(id->name.str) * 2 + 1;
 		char *name_buf = ast_alloca(name_buf_len);
 

-- 
To view, visit https://gerrit.asterisk.org/5542
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa6ffe9d92f598fe9e3c8ae373fadbe3dfbf1d4a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-code-review mailing list