Skip to content

Commit

Permalink
xcap_client: handle return code for strchr()
Browse files Browse the repository at this point in the history
(cherry picked from commit 8147009)
  • Loading branch information
miconda committed Aug 30, 2017
1 parent 6d6a51b commit 5b7ce6c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/modules/xcap_client/xcap_client.c
Expand Up @@ -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++;

Expand Down

0 comments on commit 5b7ce6c

Please sign in to comment.