struct berval bdn;
LDAPMessage *result = NULL,
*e = NULL;
- char *gattr[3];
+ char *attr[3], **attrp = NULL;
char *filter = NULL;
SlapReply rs;
int do_retry = 1;
LDAPControl **ctrls = NULL;
+ *ent = NULL;
+
/* Tell getconn this is a privileged op */
do_not_cache = op->o_do_not_cache;
op->o_do_not_cache = 1;
op->o_do_not_cache = do_not_cache;
if ( at ) {
+ attrp = attr;
if ( oc && at != slap_schema.si_ad_objectClass ) {
- gattr[0] = slap_schema.si_ad_objectClass->ad_cname.bv_val;
- gattr[1] = at->ad_cname.bv_val;
- gattr[2] = NULL;
+ attr[0] = slap_schema.si_ad_objectClass->ad_cname.bv_val;
+ attr[1] = at->ad_cname.bv_val;
+ attr[2] = NULL;
} else {
- gattr[0] = at->ad_cname.bv_val;
- gattr[1] = NULL;
+ attr[0] = at->ad_cname.bv_val;
+ attr[1] = NULL;
}
}
retry:
rc = ldap_search_ext_s( lc->lc_ld, ndn->bv_val, LDAP_SCOPE_BASE, filter,
- at ? gattr : NULL, 0, ctrls, NULL,
- LDAP_NO_LIMIT, LDAP_NO_LIMIT, &result );
+ attrp, 0, ctrls, NULL,
+ NULL, LDAP_NO_LIMIT, &result );
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_SERVER_DOWN && do_retry ) {
do_retry = 0;
e = ldap_first_entry( lc->lc_ld, result );
if ( e == NULL ) {
+ /* the entry exists, but it doesn't match the filter? */
goto cleanup;
}
*ent = ch_calloc( 1, sizeof( Entry ) );
+ if ( *ent == NULL ) {
+ rc = LDAP_NO_MEMORY;
+ goto cleanup;
+ }
rc = ldap_build_entry( op, e, *ent, &bdn );
csn = op->o_csn;
}
ptr = ber_bvchr( &csn, '#' );
- if ( ptr && ptr < &csn.bv_val[csn.bv_len] ) {
+ if ( ptr ) {
timestamp.bv_len = ptr - csn.bv_val;
- if ( timestamp.bv_len >= sizeof( timebuf ))
+ if ( timestamp.bv_len >= sizeof( timebuf )) /* ?!? */
timestamp.bv_len = sizeof( timebuf ) - 1;
- strncpy( timebuf, csn.bv_val, timestamp.bv_len );
+ AC_MEMCPY( timebuf, csn.bv_val, timestamp.bv_len );
timebuf[timestamp.bv_len] = '\0';
} else {
time_t now = slap_get_time();