[JDEV] help with pointer bug
mark at mjwilcox.com
mark at mjwilcox.com
Sun Sep 3 20:30:53 CDT 2000
Hi,
I'm sure in the end this will be something elementary, but I can't
figure it out.
I'm working on mapping jabber's registration elements to LDAP
attributes.
I have the hashtable map working and I have an array filled with the
possible Jabber registration elements.
The LDAP API uses an NULL-terminated array of LDAPMod
structures to construct the data to populate an LDAP server.
I'm using a while loop to populate this array, using a generic
function to create the LDAPMod structure for each present Jabber
element.
Here's the loop (copied directly from source:)
i = 0;
while (reg_attr[i] != NULL)
{
log_debug("xdb_ldap","reg_attr is %s\n",reg_attr[i]);
temp = ghash_get(cfg->registertab,reg_attr[i]);
if (temp == NULL)
{
log_debug("xdb_ldap","No reg LDAP mapping for %s",reg_attr[i]);
}
else
{
usermod = xdb_ldap_get_mod(temp,xmlnode_get_tag_data(data,reg_attr[i]));
log_debug("xdb_ldap","got %s from xdb_ldap_get_mod",reg_attr[i]);
}
mods[i] = (LDAPMod *)&usermod;
log_debug("xdb_ldap","mod type is %s for
%d",mods[i]->mod_type,i);
log_debug("xdb_ldap","mod type 2 is %s for
0",mods[0]->mod_type);
i++;
}
mods[i] = &ocmod;
mods[i++] = NULL;
but each element overwrites all of the data in mods. For example
lets say that the password element is the 4th element we get from
jabber. Then mods 0-3 all contain the password attribute data
instead of their previous values.
I know it's pointer poison. I'm just not sure how to cure it. After 2
weeks of putting a machine back together at work, those brain
cells are probably crashed & burning somewhere.
This is in the xdb_ldap.c module.
You can also check out the full source from CVS or browse it on
the web at:
http://xdbldap.tigris.org/source/browse/~checkout~/xdbldap/src/jab
ber-transport-1.0/src/xdb/ldap/xdb_ldap.c?rev=1.13&content-
type=text/plain
Mark
Mark Wilcox
mark at mjwilcox.com
Got LDAP?
More information about the JDev
mailing list