From 62497187c743cf6db5459d1ed80aa137722d006e Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 6 Jan 2006 16:31:07 +0000 Subject: [PATCH] cleanup --- servers/slapd/back-ldap/search.c | 24 ++++++++++++++++-------- servers/slapd/modify.c | 6 +++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 30f8d4a153..5290dc9b16 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -713,12 +713,14 @@ ldap_back_entry_get( 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; @@ -730,14 +732,15 @@ ldap_back_entry_get( 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; } } @@ -760,8 +763,8 @@ ldap_back_entry_get( 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; @@ -774,10 +777,15 @@ retry: 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 ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index e38aa87007..05891b3dbe 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -835,11 +835,11 @@ void slap_mods_opattrs( 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(); -- 2.39.5