The existing logic leaves "group" string as zero-length if the
optional groupattr_regex parameter is unset.
If groupattr_regex is unset, then processregex should not be called;
the entire string from vals[0] should be strcpy to group.
If groupattr_regex is set, then processregex should be called. If it
fails, the entire string is strcpy to group from vals[0] (I'm not sure
why, but that seems to be the intended behavior).
--- jabberd2-2.2.17.orig/storage/storage_ldapvcard.c
+++ jabberd2-2.2.17/storage/storage_ldapvcard.c
@@ -430,7 +430,7 @@
ldap_value_free(vals);
continue;
}
- if (data->groupattr_regex != NULL &&
processregex(vals[0],data->groupattr_regex,2,1,group,sizeof(group),drv) !=0) {
+ if (data->groupattr_regex == NULL ||
processregex(vals[0],data->groupattr_regex,2,1,group,sizeof(group),drv) !=0) {
strncpy(group,vals[0],sizeof(group)-1);
}
group[sizeof(group)-1]='\0';