[sr-dev] git:master:8147009b: xcap_client: handle return code for strchr()

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 24 13:01:21 CEST 2017


Module: kamailio
Branch: master
Commit: 8147009b34639304fb75d4f6c39269c49ee385ca
URL: https://github.com/kamailio/kamailio/commit/8147009b34639304fb75d4f6c39269c49ee385ca

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-24T12:15:09+02:00

xcap_client: handle return code for strchr()

---

Modified: src/modules/xcap_client/xcap_client.c

---

Diff:  https://github.com/kamailio/kamailio/commit/8147009b34639304fb75d4f6c39269c49ee385ca.diff
Patch: https://github.com/kamailio/kamailio/commit/8147009b34639304fb75d4f6c39269c49ee385ca.patch

---

diff --git a/src/modules/xcap_client/xcap_client.c b/src/modules/xcap_client/xcap_client.c
index e96511651d..0b8a707d8d 100644
--- a/src/modules/xcap_client/xcap_client.c
+++ b/src/modules/xcap_client/xcap_client.c
@@ -310,24 +310,33 @@ int parse_doc_url(str doc_url, char** serv_addr, xcap_doc_sel_t* doc_sel)
 	char* sl, *str_type;
 
 	sl= strchr(doc_url.s, '/');
+	if(sl==NULL) {
+		return -1;
+	}
 	*sl= '\0';
 	*serv_addr= doc_url.s;
 
 	sl++;
 	doc_sel->auid.s= sl;
 	sl= strchr(sl, '/');
+	if(sl==NULL) {
+		return -1;
+	}
 	doc_sel->auid.len= sl- doc_sel->auid.s;
 
 	sl++;
 	str_type= sl;
 	sl= strchr(sl, '/');
+	if(sl==NULL) {
+		return -1;
+	}
 	*sl= '\0';
 
-	if(strcasecmp(str_type, "users")== 0)
+	if(strcasecmp(str_type, "users")== 0) {
 		doc_sel->type= USERS_TYPE;
-	else
-	if(strcasecmp(str_type, "group")== 0)
+	} else if(strcasecmp(str_type, "group")== 0) {
 		doc_sel->type= GLOBAL_TYPE;
+	}
 
 	sl++;
 




More information about the sr-dev mailing list