{
int i, j, numvals = 0, nummods,
rc = LDAP_SUCCESS;
- BerVarray nvals = NULL, nmods;
+ BerVarray nvals = NULL, nmods = NULL;
/*
* FIXME: better do the following
/* count existing values */ ;
if ( numvals < nummods ) {
- nvals = ch_calloc( numvals + 1, sizeof( struct berval ) );
+ nvals = SLAP_CALLOC( numvals + 1, sizeof( struct berval ) );
+ if( nvals == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#endif
+ goto return_results;
+ }
/* normalize the existing values first */
for ( j = 0; vals[ j ].bv_val != NULL; j++ ) {
* values and test each new value against them first,
* then to other already normalized values
*/
- nmods = ch_calloc( nummods + 1, sizeof( struct berval ) );
+ nmods = SLAP_CALLOC( nummods + 1, sizeof( struct berval ) );
+ if ( nmods == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
+#endif
+ goto return_results;
+ }
for ( i = 0; mods[ i ].bv_val != NULL; i++ ) {
rc = value_normalize( ad, SLAP_MR_EQUALITY,
for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ )
/* count existing values */ ;
- nvals = (BerVarray)ch_calloc( j + 1, sizeof ( struct berval ) );
+ nvals = (BerVarray)SLAP_CALLOC( j + 1, sizeof ( struct berval ) );
+ if( nvals == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "modify_delete_values: SLAP_CALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "modify_delete_values: SLAP_CALLOC failed", 0, 0, 0 );
+#endif
+ goto return_results;
+ }
/* normalize existing values */
for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ ) {
MatchingRule *mr;
MatchingRuleUse **mru_ptr = &mru_list;
-#define MR_TYPE_MASK ( SLAP_MR_TYPE_MASK & ~SLAP_MR_EXT )
-#define MR_TYPE_SUBTYPE_MASK ( MR_TYPE_MASK | SLAP_MR_SUBTYPE_MASK )
-#if 0 /* all types regardless of EXT */
-#define MR_TYPE(x) ( (x) & MR_TYPE_MASK )
-#define MR_TYPE_SUBTYPE(x) ( (x) & MR_TYPE_SUBTYPE_MASK )
-#else /* only those marked as EXT (as per RFC 2252) */
-#define MR_TYPE(x) ( ( (x) & SLAP_MR_EXT ) ? ( (x) & MR_TYPE_MASK ) : SLAP_MR_NONE )
-#define MR_TYPE_SUBTYPE(x) ( ( (x) & SLAP_MR_EXT ) ? ( (x) & MR_TYPE_SUBTYPE_MASK ) : SLAP_MR_NONE )
-#endif
-
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "matching_rule_use_init\n", 0, 0, 0 );
#else
#endif
for ( mr = mr_list; mr; mr = mr->smr_next ) {
- slap_mask_t um = MR_TYPE( mr->smr_usage );
- slap_mask_t usm = MR_TYPE_SUBTYPE( mr->smr_usage );
-
AttributeType *at;
MatchingRuleUse _mru, *mru = &_mru;
}
if( set_flags && ( e->e_ocflags & SLAP_OC__END )) {
- return (e->e_ocflags & oc->soc_flags) ? 1 : 0;
+ return (e->e_ocflags & oc->soc_flags) == oc->soc_flags;
}
/*
}
e->e_ocflags |= SLAP_OC__END; /* We've finished this */
- return (e->e_ocflags & oc->soc_flags);
+ return (e->e_ocflags & oc->soc_flags) == oc->soc_flags;
}
if( pos ) {
int suflen = strlen(oid + pos);
- char *tmp = ch_malloc( om->som_oid.bv_len
+ char *tmp = SLAP_MALLOC( om->som_oid.bv_len
+ suflen + 1);
+ if( tmp == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR,
+ "oidm_find: SLAP_MALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "oidm_find: SLAP_MALLOC failed", 0, 0, 0 );
+#endif
+ return NULL;
+ }
strcpy(tmp, om->som_oid.bv_val);
if( suflen ) {
suflen = om->som_oid.bv_len;
return 1;
}
- om = (OidMacro *) ch_malloc( sizeof(OidMacro) );
+ om = (OidMacro *) SLAP_MALLOC( sizeof(OidMacro) );
+ if( om == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ERR, "parse_oidm: SLAP_MALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "parse_oidm: SLAP_MALLOC failed", 0, 0, 0 );
+#endif
+ return 1;
+ }
om->som_names = NULL;
ldap_charray_add( &om->som_names, argv[1] );
}
muck.bv_len = ntargetDN.bv_len + nrefDN.bv_len - nbaseDN.bv_len;
- muck.bv_val = ch_malloc( muck.bv_len + 1 );
+ muck.bv_val = SLAP_MALLOC( muck.bv_len + 1 );
+ if( muck.bv_val == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "referral_dn_muck: SLAP_MALLOC failed\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "referral_dn_muck: SLAP_MALLOC failed\n", 0, 0, 0 );
+#endif
+ return NULL;
+ }
strncpy( muck.bv_val, ntargetDN.bv_val,
ntargetDN.bv_len-nbaseDN.bv_len );
if( i < 1 ) return NULL;
- refs = ch_malloc( (i+1) * sizeof( struct berval ) );
+ refs = SLAP_MALLOC( (i+1) * sizeof( struct berval ) );
+ if( refs == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "referral_rewrite: SLAP_MALLOC failed\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "referral_rewrite: SLAP_MALLOC failed\n", 0, 0, 0 );
+#endif
+ return NULL;
+ }
for( iv=in,jv=refs; iv->bv_val != NULL ; iv++ ) {
LDAPURLDesc *url;
if( i < 1 ) return NULL;
- refs = ch_malloc( (i + 1) * sizeof(struct berval));
+ refs = SLAP_MALLOC( (i + 1) * sizeof(struct berval));
+ if( refs == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "get_entry_referrals: SLAP_MALLOC failed\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "get_entry_referrals: SLAP_MALLOC failed\n", 0, 0, 0 );
+#endif
+ return NULL;
+ }
for( iv=attr->a_vals, jv=refs; iv->bv_val != NULL; iv++ ) {
unsigned k;
/* Build the new dn */
c1 = dn->bv_val;
- dn->bv_val = ch_malloc( len+1 );
+ dn->bv_val = SLAP_MALLOC( len+1 );
+ if( dn->bv_val == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( TRANSPORT, ERR,
+ "slap_sasl_getdn: SLAP_MALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "slap_sasl_getdn: SLAP_MALLOC failed", 0, 0, 0 );
+#endif
+ return LDAP_OTHER;
+ }
p = lutil_strcopy( dn->bv_val, "uid=" );
p = lutil_strncopy( p, c1, dn->bv_len );
session_callbacks =
#if SASL_VERSION_MAJOR >= 2
- ch_calloc( 5, sizeof(sasl_callback_t));
+ SLAP_CALLOC( 5, sizeof(sasl_callback_t));
#else
- ch_calloc( 3, sizeof(sasl_callback_t));
+ SLAP_CALLOC( 3, sizeof(sasl_callback_t));
#endif
+ if( session_callbacks == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( TRANSPORT, ERR,
+ "slap_sasl_open: SLAP_MALLOC failed", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "slap_sasl_open: SLAP_MALLOC failed", 0, 0, 0 );
+#endif
+ return -1;
+ }
conn->c_sasl_extra = session_callbacks;
session_callbacks[cb=0].id = SASL_CB_LOG;
SubstringsAssertion *nsa;
int i;
- nsa = (SubstringsAssertion *)ch_calloc( 1, sizeof(SubstringsAssertion) );
+ nsa = (SubstringsAssertion *)SLAP_CALLOC( 1, sizeof(SubstringsAssertion) );
if( nsa == NULL ) {
return NULL;
}
/* empty */
}
nsa->sa_any = (struct berval *)
- ch_malloc( (i + 1) * sizeof(struct berval) );
+ SLAP_MALLOC( (i + 1) * sizeof(struct berval) );
+ if( nsa->sa_any == NULL ) {
+ goto err;
+ }
for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) {
UTF8bvnormalize( &sa->sa_any[i], &nsa->sa_any[i],
if (lset == NULL || lset->bv_val == NULL) {
if (rset == NULL) {
if (lset == NULL)
- return(ch_calloc(1, sizeof(struct berval)));
+ return(SLAP_CALLOC(1, sizeof(struct berval)));
return(lset);
}
slap_set_dispose(lset);
}
i = slap_set_size(lset) + slap_set_size(rset) + 1;
- set = ch_calloc(i, sizeof(struct berval));
+ set = SLAP_CALLOC(i, sizeof(struct berval));
if (set != NULL) {
/* set_chase() depends on this routine to
* keep the first elements of the result
if (op == '&') {
if (lset == NULL || lset->bv_val == NULL || rset == NULL || rset->bv_val == NULL) {
- set = ch_calloc(1, sizeof(struct berval));
+ set = SLAP_CALLOC(1, sizeof(struct berval));
} else {
set = lset;
lset = NULL;
bv.bv_val = attrstr;
if (set == NULL)
- return(ch_calloc(1, sizeof(struct berval)));
+ return(SLAP_CALLOC(1, sizeof(struct berval)));
if (set->bv_val == NULL)
return(set);
AC_MEMCPY(attrstr, attr->bv_val, attr->bv_len);
attrstr[attr->bv_len] = 0;
- nset = ch_calloc(1, sizeof(struct berval));
+ nset = SLAP_CALLOC(1, sizeof(struct berval));
if (nset == NULL) {
slap_set_dispose(set);
return(NULL);
if (c == 0)
SF_ERROR(syntax);
- set = ch_calloc(2, sizeof(struct berval));
+ set = SLAP_CALLOC(2, sizeof(struct berval));
if (set == NULL)
SF_ERROR(memory);
- set->bv_val = ch_calloc(len + 1, sizeof(char));
+ set->bv_val = SLAP_CALLOC(len + 1, sizeof(char));
if (set->bv_val == NULL)
SF_ERROR(memory);
AC_MEMCPY(set->bv_val, &filter[-len - 1], len);
{
if ((SF_TOP() == (void *)'/') || IS_SET(SF_TOP()))
SF_ERROR(syntax);
- set = ch_calloc(2, sizeof(struct berval));
+ set = SLAP_CALLOC(2, sizeof(struct berval));
if (set == NULL)
SF_ERROR(memory);
ber_dupbv( set, this );
{
if ((SF_TOP() == (void *)'/') || IS_SET(SF_TOP()))
SF_ERROR(syntax);
- set = ch_calloc(2, sizeof(struct berval));
+ set = SLAP_CALLOC(2, sizeof(struct berval));
if (set == NULL)
SF_ERROR(memory);
ber_dupbv( set, user );
#include "slap.h"
#include <ldap_pvt.h>
+#if 0 /* unused */
static char *find_matching_paren( const char *s );
+#endif /* unused */
static Filter *str2list( const char *str, long unsigned int ftype);
static Filter *str2simple( const char *str);
static int str2subvals( const char *val, Filter *f);
struct berval nv1 = { 0, NULL };
struct berval nv2 = { 0, NULL };
+ assert( mr != NULL );
+
if( !mr->smr_match ) {
return LDAP_INAPPROPRIATE_MATCHING;
}