X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=libraries%2Flibldap%2Fgetfilter.c;h=e6570187ccb74dcd48b43f952e0e5a477f909cd3;hb=f42966f9e1ac239213e236b93375559a1e25ba5f;hp=bf75521457ba02ae5672d473ddd14dddb2af364a;hpb=21c70857f1029309d6bc5a5b6a93d7537494b742;p=openldap diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index bf75521457..e6570187cc 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -1,5 +1,6 @@ +/* $OpenLDAP$ */ /* - * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* Portions @@ -15,7 +16,6 @@ #include -#include #include #include #include @@ -83,7 +83,7 @@ ldap_init_getfilter( LDAP_CONST char *fname ) LDAPFiltDesc * -ldap_init_getfilter_buf( char *buf, long buflen ) +ldap_init_getfilter_buf( char *buf, ber_len_t buflen ) { LDAPFiltDesc *lfdp; LDAPFiltList *flp, *nextflp; @@ -101,7 +101,7 @@ ldap_init_getfilter_buf( char *buf, long 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 ) { @@ -122,15 +122,14 @@ ldap_init_getfilter_buf( char *buf, long buflen ) nextflp->lfl_tag = LDAP_STRDUP( tag ); nextflp->lfl_pattern = tok[ 0 ]; if ( (rc = regcomp( &re, nextflp->lfl_pattern, 0 )) != 0 ) { -#ifdef LDAP_LIBUI char error[512]; regerror(rc, &re, error, sizeof(error)); ldap_getfilter_free( lfdp ); - fprintf( stderr, "bad regular expression %s, %s\n", - nextflp->lfl_pattern, error ); + Debug( LDAP_DEBUG_ANY, "ldap_init_get_filter_buf: " + "bad regular expression %s, %s\n", + nextflp->lfl_pattern, error, 0 ); errno = EINVAL; -#endif /* LDAP_LIBUI */ - free_strarray( tok ); + LDAP_VFREE( tok ); return( NULL ); } regfree(&re); @@ -156,7 +155,7 @@ ldap_init_getfilter_buf( char *buf, long 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 */ @@ -176,7 +175,7 @@ ldap_init_getfilter_buf( char *buf, long 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 ); @@ -193,7 +192,7 @@ ldap_init_getfilter_buf( char *buf, long buflen ) break; default: - free_strarray( tok ); + LDAP_VFREE( tok ); ldap_getfilter_free( lfdp ); errno = EINVAL; return( NULL ); @@ -243,17 +242,17 @@ ldap_getfirstfilter( for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) { /* compile tagpat, continue if we fail */ - if (regcomp(&re, tagpat, 0) != 0) + if (regcomp(&re, tagpat, REG_EXTENDED|REG_NOSUB) != 0) continue; - /* match tagpatern and tag, continue if we fail */ + /* match tagpattern and tag, continue if we fail */ rc = regexec(&re, flp->lfl_tag, 0, NULL, 0); regfree(&re); if (rc != 0) continue; /* compile flp->ifl_pattern, continue if we fail */ - if (regcomp(&re, flp->lfl_pattern, 0) != 0) + if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED|REG_NOSUB) != 0) continue; /* match ifl_pattern and lfd_curval, continue if we fail */ @@ -314,7 +313,7 @@ ldap_getnextfilter( LDAPFiltDesc *lfdp ) void ldap_build_filter( char *filtbuf, - unsigned long buflen, + ber_len_t buflen, LDAP_CONST char *pattern, LDAP_CONST char *prefix, LDAP_CONST char *suffix, @@ -346,12 +345,12 @@ ldap_build_filter( if ( *p == '%' ) { ++p; if ( *p == 'v' ) { - if ( isdigit( (unsigned char) p[1] )) { + if ( LDAP_DIGIT( (unsigned char) p[1] )) { ++p; wordnum = *p - '1'; if ( *(p+1) == '-' ) { ++p; - if ( isdigit( (unsigned char) p[1] )) { + if ( LDAP_DIGIT( (unsigned char) p[1] )) { ++p; endwordnum = *p - '1'; /* e.g., "%v2-4" */ if ( endwordnum > wordcount - 1 ) { @@ -370,7 +369,7 @@ ldap_build_filter( *f++ = ' '; } slen = strlen( valwords[ i ] ); - SAFEMEMCPY( f, valwords[ i ], slen ); + AC_MEMCPY( f, valwords[ i ], slen ); f += slen; } } @@ -379,17 +378,17 @@ ldap_build_filter( if ( wordcount > 0 ) { wordnum = wordcount - 1; slen = strlen( valwords[ wordnum ] ); - SAFEMEMCPY( f, valwords[ wordnum ], slen ); + AC_MEMCPY( f, valwords[ wordnum ], slen ); f += slen; } } else if ( value != NULL ) { slen = strlen( value ); - SAFEMEMCPY( f, value, slen ); + AC_MEMCPY( f, value, slen ); f += slen; } } else if ( *p == 'a' && attr != NULL ) { slen = strlen( attr ); - SAFEMEMCPY( f, attr, slen ); + AC_MEMCPY( f, attr, slen ); f += slen; } else { *f++ = *p; @@ -398,15 +397,14 @@ ldap_build_filter( *f++ = *p; } - if ( (unsigned long) (f - filtbuf) > buflen ) { + if ( (size_t) (f - filtbuf) > buflen ) { /* sanity check */ --f; break; } } - if ( suffix != NULL && ( - (unsigned long) ( f - filtbuf ) < buflen ) ) + if ( suffix != NULL && ( (size_t) (f - filtbuf) < buflen ) ) { strcpy( f, suffix ); } else {