xcap_client: handle return code for strchr()
authorDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 24 Jul 2017 10:15:09 +0000 (12:15 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 24 Jul 2017 10:15:09 +0000 (12:15 +0200)
src/modules/xcap_client/xcap_client.c

index e965116..0b8a707 100644 (file)
@@ -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++;