From 6ad1c45bd3a69a398b144b92fbcf9d6653f02607 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 7 Jun 2000 05:17:29 +0000 Subject: [PATCH] Use LDAP_VFREE and friends. Other misc code cleanup. --- build/main.dsw | 39 ------------------- include/ac/string.h | 4 +- libraries/libldap/disptmpl.c | 66 ++++++++++++++++---------------- libraries/libldap/dsparse.c | 19 +-------- libraries/libldap/getfilter.c | 10 ++--- libraries/libldap/ldap-int.h | 3 +- libraries/libldap/os-ip.c | 2 +- libraries/libldap/references.c | 2 +- libraries/libldap/request.c | 6 +-- libraries/libldap/sasl.c | 4 +- libraries/libldap/schema.c | 4 +- libraries/libldap/sort.c | 2 +- libraries/libldap/srchpref.c | 56 +++++++++++++-------------- libraries/libldap/string.c | 14 ------- libraries/libldap/tls.c | 2 +- libraries/libldap/ufn.c | 20 +++++----- libraries/liblutil/ntservice.c | 6 +-- servers/slapd/schemaparse.c | 70 +++++++++++++++++----------------- 18 files changed, 130 insertions(+), 199 deletions(-) diff --git a/build/main.dsw b/build/main.dsw index 0183427447..bc84913c00 100644 --- a/build/main.dsw +++ b/build/main.dsw @@ -87,9 +87,6 @@ Package=<4> Project_Dep_Name ldapsearch End Project Dependency Begin Project Dependency - Project_Dep_Name ldbmtest - End Project Dependency - Begin Project Dependency Project_Dep_Name ldif End Project Dependency Begin Project Dependency @@ -276,42 +273,6 @@ Package=<4> ############################################################################### -Project: "ldbmtest"=..\servers\slapd\tools\ldbmtest.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name backldbm - End Project Dependency - Begin Project Dependency - Project_Dep_Name liblber - End Project Dependency - Begin Project Dependency - Project_Dep_Name libldap_r - End Project Dependency - Begin Project Dependency - Project_Dep_Name libldbm - End Project Dependency - Begin Project Dependency - Project_Dep_Name liblutil - End Project Dependency - Begin Project Dependency - Project_Dep_Name libslapd - End Project Dependency - Begin Project Dependency - Project_Dep_Name libavl - End Project Dependency - Begin Project Dependency - Project_Dep_Name libldif - End Project Dependency -}}} - -############################################################################### - Project: "ldif"=..\servers\slapd\tools\ldif.dsp - Package Owner=<4> Package=<5> diff --git a/include/ac/string.h b/include/ac/string.h index 800a182f14..bb1c10b836 100644 --- a/include/ac/string.h +++ b/include/ac/string.h @@ -46,12 +46,10 @@ LIBLDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, const char *delim, char **pos )); -LIBLDAP_F(char *) ldap_pvt_strdup LDAP_P(( const char * s )); - #ifndef HAVE_STRDUP /* strdup() is missing, declare our own version */ # undef strdup -# define strdup(s) ldap_pvt_strdup(s) +# define strdup(s) ber_strdup(s) #else /* some systems fail to declare strdup */ LIBC_F(char *) (strdup)(); diff --git a/libraries/libldap/disptmpl.c b/libraries/libldap/disptmpl.c index 7ddad7700a..82dcfe8f3d 100644 --- a/libraries/libldap/disptmpl.c +++ b/libraries/libldap/disptmpl.c @@ -149,13 +149,13 @@ ldap_init_templates_buf( char *buf, ber_len_t buflen, *tmpllistp = prevtmpl = NULL; - if ( next_line_tokens( &buf, &buflen, &toks ) != 2 || + if ( ldap_int_next_line_tokens( &buf, &buflen, &toks ) != 2 || strcasecmp( toks[ 0 ], "version" ) != 0 ) { - free_strarray( toks ); + LDAP_VFREE( toks ); return( LDAP_TMPL_ERR_SYNTAX ); } version = atoi( toks[ 1 ] ); - free_strarray( toks ); + LDAP_VFREE( toks ); if ( version != LDAP_TEMPLATE_VERSION ) { return( LDAP_TMPL_ERR_VERSION ); } @@ -226,7 +226,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl ) for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) { nextocp = ocp->oc_next; - free_strarray( ocp->oc_objclasses ); + LDAP_VFREE( ocp->oc_objclasses ); LDAP_FREE( ocp ); } } @@ -260,7 +260,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl ) LDAP_FREE( colp->ti_label ); } if ( colp->ti_args != NULL ) { - free_strarray( colp->ti_args ); + LDAP_VFREE( colp->ti_args ); } LDAP_FREE( colp ); } @@ -457,14 +457,14 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * template name comes first */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX ); } if (( tmpl = (struct ldap_disptmpl *)LDAP_CALLOC( 1, sizeof( struct ldap_disptmpl ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); return( LDAP_TMPL_ERR_MEM ); } tmpl->dt_name = toks[ 0 ]; @@ -473,8 +473,8 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * template plural name comes next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -484,8 +484,8 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * template icon name is next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -495,8 +495,8 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * template options come next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) < 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) < 1 ) { + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -507,15 +507,15 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, } } } - free_strarray( toks ); + LDAP_VFREE( toks ); /* * object class list is next */ - while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) { + while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { if (( ocp = (struct ldap_oclist *)LDAP_CALLOC( 1, sizeof( struct ldap_oclist ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_MEM ); } @@ -535,8 +535,8 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * read name of attribute to authenticate as */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -550,8 +550,8 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * read default attribute to use for RDN */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -561,8 +561,8 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * read default location for new entries */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -576,7 +576,7 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, /* * read list of rules used to define default values for new entries */ - while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) { + while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { if ( strcasecmp( ADDEF_CONSTANT, toks[ 0 ] ) == 0 ) { adsource = LDAP_ADSRC_CONSTANTVALUE; } else if ( strcasecmp( ADDEF_ADDERSDN, toks[ 0 ] ) == 0 ) { @@ -587,14 +587,14 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, if ( adsource == 0 || tokcnt < 2 || ( adsource == LDAP_ADSRC_CONSTANTVALUE && tokcnt != 3 ) || ( adsource == LDAP_ADSRC_ADDERSDN && tokcnt != 2 )) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } if (( adp = (struct ldap_adddeflist *)LDAP_CALLOC( 1, sizeof( struct ldap_adddeflist ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_MEM ); } @@ -618,17 +618,17 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, * item list is next */ samerow = 0; - while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) { + while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { if ( strcasecmp( toks[ 0 ], "item" ) == 0 ) { if ( tokcnt < 4 ) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } if (( ip = (struct ldap_tmplitem *)LDAP_CALLOC( 1, sizeof( struct ldap_tmplitem ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_MEM ); } @@ -644,7 +644,7 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, } } if ( itemoptions[ i ] == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -657,7 +657,7 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, } } if ( itemtypes[ i ] == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } @@ -698,10 +698,10 @@ read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, previp = ip; samerow = 0; } else if ( strcasecmp( toks[ 0 ], "samerow" ) == 0 ) { - free_strarray( toks ); + LDAP_VFREE( toks ); samerow = 1; } else { - free_strarray( toks ); + LDAP_VFREE( toks ); free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_SYNTAX ); } diff --git a/libraries/libldap/dsparse.c b/libraries/libldap/dsparse.c index fd6be6baa4..8ec7116fd9 100644 --- a/libraries/libldap/dsparse.c +++ b/libraries/libldap/dsparse.c @@ -39,9 +39,8 @@ static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep )); static char *next_token LDAP_P(( char ** sp )); - int -next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp ) +ldap_int_next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp ) { char *p, *line, *token, **toks; int rc, tokcnt; @@ -72,7 +71,7 @@ next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp ) if ( tokcnt == 1 && strcasecmp( toks[ 0 ], "END" ) == 0 ) { tokcnt = 0; - free_strarray( toks ); + LDAP_VFREE( toks ); toks = NULL; } @@ -195,17 +194,3 @@ next_token( char **sp ) return( LDAP_STRDUP( tokstart )); } - - -void -free_strarray( char **sap ) -{ - int i; - - if ( sap != NULL ) { - for ( i = 0; sap[ i ] != NULL; ++i ) { - LBER_FREE( sap[ i ] ); - } - LBER_FREE( (char *)sap ); - } -} diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index ff20388adc..2d8b89c8a8 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -102,7 +102,7 @@ ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) fip = NULL; tag = NULL; - while ( buflen > 0 && ( tokcnt = next_line_tokens( &buf, &buflen, &tok )) + while ( buflen > 0 && ( tokcnt = ldap_int_next_line_tokens( &buf, &buflen, &tok )) > 0 ) { switch( tokcnt ) { @@ -131,7 +131,7 @@ ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) nextflp->lfl_pattern, error ); errno = EINVAL; #endif /* LDAP_LIBUI */ - free_strarray( tok ); + LDAP_VFREE( tok ); return( NULL ); } regfree(&re); @@ -157,7 +157,7 @@ ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) if (( nextfip = (LDAPFiltInfo *)LDAP_CALLOC( 1, sizeof( LDAPFiltInfo ))) == NULL ) { ldap_getfilter_free( lfdp ); - free_strarray( tok ); + LDAP_VFREE( tok ); return( NULL ); } if ( fip == NULL ) { /* first one */ @@ -177,7 +177,7 @@ ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) } else if ( strcasecmp( tok[ 2 ], "base" ) == 0 ) { nextfip->lfi_scope = LDAP_SCOPE_BASE; } else { - free_strarray( tok ); + LDAP_VFREE( tok ); ldap_getfilter_free( lfdp ); errno = EINVAL; return( NULL ); @@ -194,7 +194,7 @@ ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) break; default: - free_strarray( tok ); + LDAP_VFREE( tok ); ldap_getfilter_free( lfdp ); errno = EINVAL; return( NULL ); diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 743a221ab2..f9cde12e14 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -356,8 +356,7 @@ LIBLDAP_F (int) ldap_int_put_controls LDAP_P(( /* * in dsparse.c */ -LIBLDAP_F (int) next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp )); -LIBLDAP_F (void) free_strarray LDAP_P(( char **sap )); +LIBLDAP_F (int) ldap_int_next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp )); #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND /* diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index f150eb4ff6..e300711817 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -67,7 +67,7 @@ ldap_int_timeval_dup( struct timeval **dest, const struct timeval *src ) return 0; } - new = (struct timeval *) malloc(sizeof(struct timeval)); + new = (struct timeval *) LDAP_MALLOC(sizeof(struct timeval)); if( new == NULL ) { *dest = NULL; diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c index 01fc076304..c42f652057 100644 --- a/libraries/libldap/references.c +++ b/libraries/libldap/references.c @@ -132,7 +132,7 @@ free_and_return: *referralsp = refs; } else { - ldap_value_free( refs ); + LDAP_VFREE( refs ); } if( freeit ) { diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index ec6ee54274..033914e899 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -419,7 +419,7 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) if( lc->lconn_rebind_queue != NULL) { int i; for( i = 0; lc->lconn_rebind_queue[i] != NULL; i++) { - free_strarray(lc->lconn_rebind_queue[i]); + LDAP_VFREE(lc->lconn_rebind_queue[i]); } LDAP_FREE( lc->lconn_rebind_queue); } @@ -723,7 +723,7 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, char **errstrp, if( lc->lconn_rebind_queue != NULL) { /* Release resources of previous list */ - free_strarray(refarray); + LDAP_VFREE(refarray); refarray = NULL; ldap_free_urllist(srv); srv = NULL; @@ -747,7 +747,7 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, char **errstrp, } } /* end for loop */ done: - free_strarray(refarray); + LDAP_VFREE(refarray); ldap_free_urllist(srv); LDAP_FREE( *errstrp ); diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index ed9308f653..de430695f9 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -742,12 +742,12 @@ ldap_pvt_sasl_getmechs ( LDAP *ld, char **pmechlist ) mechlist = array2str( values ); if ( mechlist == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; - ldap_value_free( values ); + LDAP_VFREE( values ); ldap_msgfree( res ); return ld->ld_errno; } - ldap_value_free( values ); + LDAP_VFREE( values ); ldap_msgfree( res ); *pmechlist = mechlist; diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 3f16668ed2..cae5dfc660 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -1961,7 +1961,7 @@ ldap_str2objectclass( const char * s, int * code, const char ** errp, const int } static char *const err2text[] = { - "", + "Success", "Out of memory", "Unexpected token", "Missing opening parenthesis", @@ -1977,7 +1977,7 @@ static char *const err2text[] = { char * ldap_scherr2str(int code) { - if ( code < 1 || code >= (sizeof(err2text)/sizeof(char *)) ) { + if ( code < 0 || code >= (sizeof(err2text)/sizeof(char *)) ) { return "Unknown error"; } else { return err2text[code]; diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index 288ff85454..5734022c58 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -135,7 +135,7 @@ ldap_sort_entries( *ep = et[i].et_msg; ep = &(*ep)->lm_chain; - ldap_value_free( et[i].et_vals ); + LDAP_VFREE( et[i].et_vals ); } *ep = last; LDAP_FREE( (char *) et ); diff --git a/libraries/libldap/srchpref.c b/libraries/libldap/srchpref.c index 4b54189c70..8f34f509f2 100644 --- a/libraries/libldap/srchpref.c +++ b/libraries/libldap/srchpref.c @@ -111,13 +111,13 @@ ldap_init_searchprefs_buf( *solistp = prevso = NULL; - if ( next_line_tokens( &buf, &buflen, &toks ) != 2 || + if ( ldap_int_next_line_tokens( &buf, &buflen, &toks ) != 2 || strcasecmp( toks[ 0 ], "version" ) != 0 ) { - free_strarray( toks ); + LDAP_VFREE( toks ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } version = atoi( toks[ 1 ] ); - free_strarray( toks ); + LDAP_VFREE( toks ); if ( version != LDAP_SEARCHPREF_VERSION && version != LDAP_SEARCHPREF_VERSION_ZERO ) { return( LDAP_SEARCHPREF_ERR_VERSION ); @@ -250,14 +250,14 @@ read_next_searchobj( /* * Object type prompt comes first */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); return( tokcnt == 0 ? 0 : LDAP_SEARCHPREF_ERR_SYNTAX ); } if (( so = (struct ldap_searchobj *)LDAP_CALLOC( 1, sizeof( struct ldap_searchobj ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); return( LDAP_SEARCHPREF_ERR_MEM ); } so->so_objtypeprompt = toks[ 0 ]; @@ -267,8 +267,8 @@ read_next_searchobj( * if this is post-version zero, options come next */ if ( soversion > LDAP_SEARCHPREF_VERSION_ZERO ) { - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) < 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) < 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -279,14 +279,14 @@ read_next_searchobj( } } } - free_strarray( toks ); + LDAP_VFREE( toks ); } /* * "Fewer choices" prompt is next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -296,8 +296,8 @@ read_next_searchobj( /* * Filter prefix for "More Choices" searching is next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -307,8 +307,8 @@ read_next_searchobj( /* * "Fewer Choices" filter tag comes next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -318,8 +318,8 @@ read_next_searchobj( /* * Selection (disambiguation) attribute comes next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -329,8 +329,8 @@ read_next_searchobj( /* * Label for selection (disambiguation) attribute */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -340,8 +340,8 @@ read_next_searchobj( /* * Search scope is next */ - if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) { - free_strarray( toks ); + if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } @@ -355,22 +355,22 @@ read_next_searchobj( ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } - free_strarray( toks ); + LDAP_VFREE( toks ); /* * "More Choices" search option list comes next */ sa = &( so->so_salist ); - while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) { + while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { if ( tokcnt < 5 ) { - free_strarray( toks ); + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } if (( *sa = ( struct ldap_searchattr * ) LDAP_CALLOC( 1, sizeof( struct ldap_searchattr ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_MEM ); } @@ -395,15 +395,15 @@ read_next_searchobj( * Match types are last */ sm = &( so->so_smlist ); - while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) { + while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { if ( tokcnt < 2 ) { - free_strarray( toks ); + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } if (( *sm = ( struct ldap_searchmatch * ) LDAP_CALLOC( 1, sizeof( struct ldap_searchmatch ))) == NULL ) { - free_strarray( toks ); + LDAP_VFREE( toks ); ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_MEM ); } diff --git a/libraries/libldap/string.c b/libraries/libldap/string.c index 21598fe004..df8069ccaa 100644 --- a/libraries/libldap/string.c +++ b/libraries/libldap/string.c @@ -97,20 +97,6 @@ char *(ldap_pvt_strtok)( char *str, const char *delim, char **pos ) return str; } -char * -(ldap_pvt_strdup)( const char *s ) -{ - char *p; - size_t len = strlen( s ) + 1; - - if ( (p = (char *) malloc( len )) == NULL ) { - return( NULL ); - } - - memcpy( p, s, len ); - return( p ); -} - char * ldap_pvt_str2upper( char *str ) { diff --git a/libraries/libldap/tls.c b/libraries/libldap/tls.c index ff72666090..20e5a2b4ad 100644 --- a/libraries/libldap/tls.c +++ b/libraries/libldap/tls.c @@ -566,7 +566,7 @@ ldap_pvt_tls_connect( LDAP *ld, Sockbuf *sb, void *ctx_arg ) return 1; if ((err = ERR_peek_error())) { char buf[256]; - ld->ld_error = ldap_strdup(ERR_error_string(err, buf)); + ld->ld_error = LDAP_STRDUP(ERR_error_string(err, buf)); } Debug( LDAP_DEBUG_ANY,"TLS: can't connect.\n",0,0,0); ber_sockbuf_remove_io( sb, &ldap_pvt_sockbuf_io_tls, diff --git a/libraries/libldap/ufn.c b/libraries/libldap/ufn.c index 50f4dc0352..d5e1a5206b 100644 --- a/libraries/libldap/ufn.c +++ b/libraries/libldap/ufn.c @@ -185,7 +185,7 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, if ( err == -1 || err == LDAP_USER_CANCELLED ) { if ( dns != NULL ) { - ldap_value_free( dns ); + LDAP_VFREE( dns ); dns = NULL; } return( err ); @@ -198,7 +198,7 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, goto tryagain; } else { if ( dns != NULL ) { - ldap_value_free( dns ); + LDAP_VFREE( dns ); dns = NULL; } return( err ); @@ -209,7 +209,7 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, if ( phase == 1 ) phase++; if ( dns != NULL ) { - ldap_value_free( dns ); + LDAP_VFREE( dns ); dns = NULL; } } @@ -246,7 +246,7 @@ ldap_ufn_search_ct( attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 ); if ( ldap_count_entries( ld, *res ) > 0 ) { - ldap_value_free( ufncomp ); + LDAP_VFREE( ufncomp ); return( err ); } else { ldap_msgfree( *res ); @@ -255,21 +255,21 @@ ldap_ufn_search_ct( } if ( ld->ld_ufnprefix == NULL ) { - ldap_value_free( ufncomp ); + LDAP_VFREE( ufncomp ); return( err ); } /* if that failed, or < 2 components, use the prefix */ if ( (prefixcomp = ldap_explode_dn( ld->ld_ufnprefix, 0 )) == NULL ) { - ldap_value_free( ufncomp ); + LDAP_VFREE( ufncomp ); return( ld->ld_errno = LDAP_LOCAL_ERROR ); } for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ ) ; /* NULL */ if ( (pbuf = (char *) LDAP_MALLOC( strlen( ld->ld_ufnprefix ) + 1 )) == NULL ) { - ldap_value_free( ufncomp ); - ldap_value_free( prefixcomp ); + LDAP_VFREE( ufncomp ); + LDAP_VFREE( prefixcomp ); return( ld->ld_errno = LDAP_NO_MEMORY ); } @@ -293,8 +293,8 @@ ldap_ufn_search_ct( } } - ldap_value_free( ufncomp ); - ldap_value_free( prefixcomp ); + LDAP_VFREE( ufncomp ); + LDAP_VFREE( prefixcomp ); LDAP_FREE( pbuf ); return( err ); diff --git a/libraries/liblutil/ntservice.c b/libraries/liblutil/ntservice.c index 45f6e8adb4..657974ae7c 100644 --- a/libraries/liblutil/ntservice.c +++ b/libraries/liblutil/ntservice.c @@ -337,9 +337,9 @@ void LogSlapdStartedEvent( char *svc, int slap_debug, char *configfile, char *ur Inserts[i] = (char *)malloc( 20 ); itoa( slap_debug, Inserts[i++], 10 ); - Inserts[i++] = ldap_pvt_strdup( configfile ); - Inserts[i++] = ldap_pvt_strdup( urls ? urls : "ldap:///" ); - Inserts[i++] = ldap_pvt_strdup( is_NT_Service ? "svc" : "cmd" ); + Inserts[i++] = strdup( configfile ); + Inserts[i++] = strdup( urls ? urls : "ldap:///" ); + Inserts[i++] = strdup( is_NT_Service ? "svc" : "cmd" ); ReportEvent( hEventLog, EVENTLOG_INFORMATION_TYPE, 0, MSG_SLAPD_STARTED, NULL, i, 0, (LPCSTR *) Inserts, NULL ); diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index add1166a3e..8350b877b7 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -22,7 +22,7 @@ static void oc_usage(void) LDAP_GCCATTR((noreturn)); static void at_usage(void) LDAP_GCCATTR((noreturn)); static char *const err2text[] = { - "Unknown Error", + "Success", "Out of memory", "ObjectClass not found", "AttributeType not found", @@ -40,8 +40,8 @@ static char *const err2text[] = { char * scherr2str(int code) { - if ( code < 1 || code >= (sizeof(err2text)/sizeof(char *)) ) { - return err2text[0]; + if ( code < 0 || code >= (sizeof(err2text)/sizeof(char *)) ) { + return "Unknown error"; } else { return err2text[code]; } @@ -206,17 +206,18 @@ parse_oc( static void oc_usage( void ) { - fprintf( stderr, "ObjectClassDescription = \"(\" whsp\n"); - fprintf( stderr, " numericoid whsp ; ObjectClass identifier\n"); - fprintf( stderr, " [ \"NAME\" qdescrs ]\n"); - fprintf( stderr, " [ \"DESC\" qdstring ]\n"); - fprintf( stderr, " [ \"OBSOLETE\" whsp ]\n"); - fprintf( stderr, " [ \"SUP\" oids ] ; Superior ObjectClasses\n"); - fprintf( stderr, " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n"); - fprintf( stderr, " ; default structural\n"); - fprintf( stderr, " [ \"MUST\" oids ] ; AttributeTypes\n"); - fprintf( stderr, " [ \"MAY\" oids ] ; AttributeTypes\n"); - fprintf( stderr, "whsp \")\"\n"); + fprintf( stderr, + "ObjectClassDescription = \"(\" whsp\n" + " numericoid whsp ; ObjectClass identifier\n" + " [ \"NAME\" qdescrs ]\n" + " [ \"DESC\" qdstring ]\n" + " [ \"OBSOLETE\" whsp ]\n" + " [ \"SUP\" oids ] ; Superior ObjectClasses\n" + " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n" + " ; default structural\n" + " [ \"MUST\" oids ] ; AttributeTypes\n" + " [ \"MAY\" oids ] ; AttributeTypes\n" + " whsp \")\"\n" ); exit( EXIT_FAILURE ); } @@ -224,26 +225,27 @@ oc_usage( void ) static void at_usage( void ) { - fprintf( stderr, "AttributeTypeDescription = \"(\" whsp\n"); - fprintf( stderr, " numericoid whsp ; AttributeType identifier\n"); - fprintf( stderr, " [ \"NAME\" qdescrs ] ; name used in AttributeType\n"); - fprintf( stderr, " [ \"DESC\" qdstring ] ; description\n"); - fprintf( stderr, " [ \"OBSOLETE\" whsp ]\n"); - fprintf( stderr, " [ \"SUP\" woid ] ; derived from this other\n"); - fprintf( stderr, " ; AttributeType\n"); - fprintf( stderr, " [ \"EQUALITY\" woid ] ; Matching Rule name\n"); - fprintf( stderr, " [ \"ORDERING\" woid ] ; Matching Rule name\n"); - fprintf( stderr, " [ \"SUBSTR\" woid ] ; Matching Rule name\n"); - fprintf( stderr, " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n"); - fprintf( stderr, " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n"); - fprintf( stderr, " [ \"COLLECTIVE\" whsp ] ; default not collective\n"); - fprintf( stderr, " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n"); - fprintf( stderr, " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n"); - fprintf( stderr, " ; userApplications\n"); - fprintf( stderr, " ; directoryOperation\n"); - fprintf( stderr, " ; distributedOperation\n"); - fprintf( stderr, " ; dSAOperation\n"); - fprintf( stderr, "whsp \")\"\n"); + fprintf( stderr, + "AttributeTypeDescription = \"(\" whsp\n" + " numericoid whsp ; AttributeType identifier\n" + " [ \"NAME\" qdescrs ] ; name used in AttributeType\n" + " [ \"DESC\" qdstring ] ; description\n" + " [ \"OBSOLETE\" whsp ]\n" + " [ \"SUP\" woid ] ; derived from this other\n" + " ; AttributeType\n" + " [ \"EQUALITY\" woid ] ; Matching Rule name\n" + " [ \"ORDERING\" woid ] ; Matching Rule name\n" + " [ \"SUBSTR\" woid ] ; Matching Rule name\n" + " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n" + " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n" + " [ \"COLLECTIVE\" whsp ] ; default not collective\n" + " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n" + " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n" + " ; userApplications\n" + " ; directoryOperation\n" + " ; distributedOperation\n" + " ; dSAOperation\n" + " whsp \")\"\n"); exit( EXIT_FAILURE ); } -- 2.39.5