/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2005-2008 The OpenLDAP Foundation.
+ * Copyright 2005-2009 The OpenLDAP Foundation.
* Portions copyright 2004-2005 Symas Corporation.
* All rights reserved.
*
if ( dd ) {
len = snprintf( ptr, size, "%d+", dd );
- assert( len >= 0 && len < size );
+ assert( len >= 0 && (unsigned) len < size );
size -= len;
ptr += len;
}
len = snprintf( ptr, size, "%02d:%02d", hh, mm );
- assert( len >= 0 && len < size );
+ assert( len >= 0 && (unsigned) len < size );
size -= len;
ptr += len;
if ( ss ) {
len = snprintf( ptr, size, ":%02d", ss );
- assert( len >= 0 && len < size );
+ assert( len >= 0 && (unsigned) len < size );
size -= len;
ptr += len;
}
a = attr_find( rs->sr_entry->e_attrs,
slap_schema.si_ad_entryCSN );
if ( a ) {
- int len = a->a_vals[0].bv_len;
- if ( len > pd->csn.bv_len )
- len = pd->csn.bv_len;
- if ( memcmp( a->a_vals[0].bv_val, pd->csn.bv_val, len ) > 0 ) {
- AC_MEMCPY( pd->csn.bv_val, a->a_vals[0].bv_val, len );
+ ber_len_t len = a->a_nvals[0].bv_len;
+ /* Paranoid len check, normalized CSNs are always the same length */
+ if ( len > LDAP_PVT_CSNSTR_BUFSIZE )
+ len = LDAP_PVT_CSNSTR_BUFSIZE;
+ if ( memcmp( a->a_nvals[0].bv_val, pd->csn.bv_val, len ) > 0 ) {
+ AC_MEMCPY( pd->csn.bv_val, a->a_nvals[0].bv_val, len );
pd->csn.bv_len = len;
}
}
AttributeAssertion ava = ATTRIBUTEASSERTION_INIT;
purge_data pd = {0};
char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE];
- char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
+ char csnbuf[LDAP_PVT_CSNSTR_BUFSIZE];
time_t old = slap_get_time();
connection_fake_init( &conn, &opbuf, ctx );
struct berval *valp )
{
struct berval val, bv;
- int i;
+ ber_len_t i;
int rc = LDAP_SUCCESS;
assert( valp != NULL );
}
if ( !BER_BVISNULL( &ctrls[ i ]->ldctl_value ) ) {
- int j;
+ ber_len_t j;
ptr = lutil_strcopy( ptr, " controlValue \"" );
for ( j = 0; j < ctrls[ i ]->ldctl_value.bv_len; j++ )
}
rdn.bv_len = snprintf( rdn.bv_val, sizeof( rdnbuf ), "%lu", op->o_connid );
- if ( rdn.bv_len >= 0 || rdn.bv_len < sizeof( rdnbuf ) ) {
+ if ( rdn.bv_len < sizeof( rdnbuf ) ) {
attr_merge_one( e, ad_reqSession, &rdn, NULL );
} /* else? */
attr_merge_one( e, ad_reqMessage, &bv, NULL );
}
bv.bv_len = snprintf( timebuf, sizeof( timebuf ), "%d", rs->sr_err );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
bv.bv_val = timebuf;
attr_merge_one( e, ad_reqResult, &bv, NULL );
}
i += a->a_numvals;
}
}
- vals = ch_malloc( (i + 1) * sizeof( struct berval ) );
- i = 0;
- for ( a=old->e_attrs; a; a=a->a_next ) {
- if ( a->a_vals && a->a_flags ) {
- for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
- accesslog_val2val( a->a_desc, b, 0, &vals[i] );
+ if ( i ) {
+ vals = ch_malloc( (i + 1) * sizeof( struct berval ) );
+ i = 0;
+ for ( a=old->e_attrs; a; a=a->a_next ) {
+ if ( a->a_vals && a->a_flags ) {
+ for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
+ accesslog_val2val( a->a_desc, b, 0, &vals[i] );
+ }
}
}
+ vals[i].bv_val = NULL;
+ vals[i].bv_len = 0;
+ a = attr_alloc( ad_reqOld );
+ a->a_numvals = i;
+ a->a_vals = vals;
+ a->a_nvals = vals;
+ last_attr->a_next = a;
}
- vals[i].bv_val = NULL;
- vals[i].bv_len = 0;
- a = attr_alloc( ad_reqOld );
- a->a_numvals = i;
- a->a_vals = vals;
- a->a_nvals = vals;
- last_attr->a_next = a;
}
if ( logop == LOG_EN_MODIFY ) {
break;
}
bv.bv_val = timebuf;
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", rs->sr_nentries );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqEntries, &bv, NULL );
} /* else? */
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->ors_tlimit );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqTimeLimit, &bv, NULL );
} /* else? */
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->ors_slimit );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqSizeLimit, &bv, NULL );
} /* else? */
break;
case LOG_EN_BIND:
bv.bv_val = timebuf;
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->o_protocol );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqVersion, &bv, NULL );
} /* else? */
if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
int rc;
Entry *e;
- op->o_bd->bd_info = on->on_info->oi_orig;
+ op->o_bd->bd_info = (BackendInfo *)on->on_info;
rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &e );
if ( e ) {
if ( test_filter( op, e, li->li_oldf ) == LDAP_COMPARE_TRUE )
e = accesslog_entry( op, rs, LOG_EN_ABANDON, &op2 );
bv.bv_val = buf;
bv.bv_len = snprintf( buf, sizeof( buf ), "%d", op->orn_msgid );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( buf ) ) {
+ if ( bv.bv_len < sizeof( buf ) ) {
attr_merge_one( e, ad_reqId, &bv, NULL );
} /* else? */