From 8a3d02bf6b7d628ae3bfa601294b4403841c07d2 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 23 Jul 2002 18:35:12 +0000 Subject: [PATCH] misc cleanup --- servers/slapd/acl.c | 4 ++-- servers/slapd/aclparse.c | 5 ++-- servers/slapd/backend.c | 3 +++ servers/slapd/config.c | 49 ++++++++++++++++++++++----------------- servers/slapd/result.c | 2 +- servers/slapd/root_dse.c | 14 +++++------ servers/slapd/saslauthz.c | 9 ++++--- 7 files changed, 47 insertions(+), 39 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index c2f8641db8..ae19ed8480 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -1906,7 +1906,7 @@ regex_matches( ) { regex_t re; - char newbuf[512]; + char newbuf[ACL_BUF_SIZE]; struct berval bv; int rc; @@ -1917,7 +1917,7 @@ regex_matches( string_expand(&bv, pat, buf, matches); if (( rc = regcomp(&re, newbuf, REG_EXTENDED|REG_ICASE))) { - char error[512]; + char error[ACL_BUF_SIZE]; regerror(rc, &re, error, sizeof(error)); #ifdef NEW_LOGGING diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 02703af470..4af093f1a0 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -201,8 +201,7 @@ parse_acl( } if ( strcasecmp( left, "filter" ) == 0 ) { - if ( (a->acl_filter = str2filter( - right )) == NULL ) { + if ( (a->acl_filter = str2filter( right )) == NULL ) { fprintf( stderr, "%s: line %d: bad filter \"%s\" in to clause\n", fname, lineno, right ); @@ -227,7 +226,7 @@ parse_acl( } if ( a->acl_dn_pat.bv_len != 0 && - strcmp(a->acl_dn_pat.bv_val, "*") == 0) + strcmp(a->acl_dn_pat.bv_val, "*") == 0 ) { free( a->acl_dn_pat.bv_val ); a->acl_dn_pat.bv_val = NULL; diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index a9d5253785..5d14ba91d4 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -1026,6 +1026,7 @@ backend_group( } ldap_pvt_thread_mutex_lock( &conn->c_mutex ); + for (g = conn->c_groups; g; g=g->ga_next) { if (g->ga_be != be || g->ga_oc != group_oc || g->ga_at != group_at || g->ga_len != gr_ndn->bv_len) @@ -1033,7 +1034,9 @@ backend_group( if (strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0) break; } + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); + if (g) { return g->ga_res; } diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 656fb12d71..5362cbdb9e 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -2275,22 +2275,29 @@ fp_parse_line( token = strtok_quote( line, " \t" ); logline = line; - if ( token && - (strcasecmp( token, "rootpw" ) == 0 || - strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */ - strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */ - strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */ - strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */ - sprintf( logline = logbuf, "%s ***", token ); - if ( strtok_quote_ptr ) + + if ( token && ( strcasecmp( token, "rootpw" ) == 0 || + strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */ + strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */ + strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */ + strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */ + { + snprintf( logline = logbuf, sizeof logbuf, "%s ***", token ); + } + + if ( strtok_quote_ptr ) { *strtok_quote_ptr = ' '; + } + #ifdef NEW_LOGGING LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 ); #else Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 ); #endif - if ( strtok_quote_ptr ) + + if ( strtok_quote_ptr ) { *strtok_quote_ptr = '\0'; + } for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) { if ( cargc == cargv_size - 1 ) { @@ -2373,18 +2380,18 @@ strtok_quote( char *line, char *sep ) static char buf[BUFSIZ]; static char *line; -static int lmax, lcur; - -#define CATLINE( buf ) { \ - int len; \ - len = strlen( buf ); \ - while ( lcur + len + 1 > lmax ) { \ - lmax += BUFSIZ; \ - line = (char *) ch_realloc( line, lmax ); \ - } \ - strcpy( line + lcur, buf ); \ - lcur += len; \ -} +static size_t lmax, lcur; + +#define CATLINE( buf ) \ + do { \ + size_t len = strlen( buf ); \ + while ( lcur + len + 1 > lmax ) { \ + lmax += BUFSIZ; \ + line = (char *) ch_realloc( line, lmax ); \ + } \ + strcpy( line + lcur, buf ); \ + lcur += len; \ + } while( 0 ) static char * fp_getline( FILE *fp, int *lineno ) diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 8ed77725da..96a2ef1337 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -593,7 +593,7 @@ send_search_result( { char nbuf[64]; - sprintf( nbuf, "%d nentries=%d", err, nentries ); + snprintf( nbuf, sizeof nbuf, "%d nentries=%d", err, nentries ); Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu SEARCH RESULT tag=%lu err=%s text=%s\n", diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index e814c5155d..62c2fc7cf0 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -20,11 +20,11 @@ #include "lber_pvt.h" static struct berval supportedFeatures[] = { - BER_BVC("1.3.6.1.4.1.4203.1.5.1"), /* all Operational Attributes ("+") */ - BER_BVC("1.3.6.1.4.1.4203.1.5.2"), /* OCs in Attributes List */ - BER_BVC("1.3.6.1.4.1.4203.1.5.3"), /* (&) and (|) search filters */ - BER_BVC("1.3.6.1.4.1.4203.1.5.4"), /* Language Tag Options */ - BER_BVC("1.3.6.1.4.1.4203.1.5.5"), /* Language Range Options */ + BER_BVC(LDAP_FEATURE_ALL_OPERATIONAL_ATTRS), /* all Operational Attributes ("+") */ + BER_BVC(LDAP_FEATURE_OBJECTCLASS_ATTRS), /* OCs in Attributes List */ + BER_BVC(LDAP_FEATURE_ABSOLUTE_FILTERS), /* (&) and (|) search filters */ + BER_BVC(LDAP_FEATURE_LANGUAGE_TAG_OPTIONS), /* Language Tag Options */ + BER_BVC(LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS), /* Language Range Options */ {0,NULL} }; @@ -36,7 +36,6 @@ root_dse_info( Entry **entry, const char **text ) { - char buf[BUFSIZ]; Entry *e; struct berval vals[2], *bv; int i, j; @@ -122,13 +121,14 @@ root_dse_info( /* supportedLDAPVersion */ for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) { + char buf[BUFSIZ]; if (!( global_allows & SLAP_ALLOW_BIND_V2 ) && ( i < LDAP_VERSION3 ) ) { /* version 2 and lower are disallowed */ continue; } - sprintf(buf,"%d",i); + snprintf(buf, sizeof buf, "%d", i); vals[0].bv_val = buf; vals[0].bv_len = strlen( vals[0].bv_val ); attr_merge( e, ad_supportedLDAPVersion, vals ); diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index ea2fa2430f..ba3b137573 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -1,3 +1,7 @@ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ /* * Copyright (c) 2000, Mark Adamson, Carnegie Mellon. All rights reserved. * This software is not subject to any license of Carnegie Mellon University. @@ -193,11 +197,9 @@ static int slap_sasl_rx_off(char *rep, int *off) off[n] = -1; return( LDAP_SUCCESS ); } -#endif /* HAVE_CYRUS_SASL */ int slap_sasl_regexp_config( const char *match, const char *replace ) { -#ifdef HAVE_CYRUS_SASL const char *c; int rc, n; SaslRegexp_t *reg; @@ -265,13 +267,10 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) } nSaslRegexp++; -#endif return( LDAP_SUCCESS ); } -#ifdef HAVE_CYRUS_SASL - /* Perform replacement on regexp matches */ static void slap_sasl_rx_exp( char *rep, int *off, regmatch_t *str, char *saslname, struct berval *out ) -- 2.39.5