]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/str2filter.c
Backout the input exhaustion change, it loops. Still looking for
[openldap] / servers / slapd / str2filter.c
index cf95d922e8a081e832ae01ebd72c7b7a7af2a09c..3fce185f77bd49a5f5953d651ad08b04c91702d7 100644 (file)
@@ -1,15 +1,19 @@
 /* str2filter.c - parse an rfc 1588 string filter */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 
-static char    *find_matching_paren();
-static Filter  *str2list();
-static Filter  *str2simple();
-static int     str2subvals();
+static char    *find_matching_paren(char *s);
+static Filter  *str2list(char *str, long unsigned int ftype);
+static Filter  *str2simple(char *str);
+static int     str2subvals(char *val, Filter *f);
 
 Filter *
 str2filter( char *str )
@@ -97,7 +101,7 @@ str2list( char *str, unsigned long ftype )
        fp = &f->f_list;
 
        while ( *str ) {
-               while ( *str && isspace( *str ) )
+               while ( *str && isspace( (unsigned char) *str ) )
                        str++;
                if ( *str == '\0' )
                        break;
@@ -163,7 +167,7 @@ str2simple( char *str )
                        f->f_choice = LDAP_FILTER_PRESENT;
                } else {
                        f->f_choice = LDAP_FILTER_SUBSTRINGS;
-                       f->f_sub_type = strdup( str );
+                       f->f_sub_type = ch_strdup( str );
                        if ( str2subvals( value, f ) != 0 ) {
                                filter_free( f );
                                *(value-1) = '=';
@@ -176,10 +180,10 @@ str2simple( char *str )
        }
 
        if ( f->f_choice == LDAP_FILTER_PRESENT ) {
-               f->f_type = strdup( str );
+               f->f_type = ch_strdup( str );
        } else {
-               f->f_avtype = strdup( str );
-               f->f_avvalue.bv_val = strdup( value );
+               f->f_avtype = ch_strdup( str );
+               f->f_avvalue.bv_val = ch_strdup( value );
                f->f_avvalue.bv_len = strlen( value );
        }
 
@@ -202,11 +206,11 @@ str2subvals( char *val, Filter *f )
                        *nextstar++ = '\0';
 
                if ( gotstar == 0 ) {
-                       f->f_sub_initial = strdup( val );
+                       f->f_sub_initial = ch_strdup( val );
                } else if ( nextstar == NULL ) {
-                       f->f_sub_final = strdup( val );
+                       f->f_sub_final = ch_strdup( val );
                } else {
-                       charray_add( &f->f_sub_any, strdup( val ) );
+                       charray_add( &f->f_sub_any, ch_strdup( val ) );
                }
 
                gotstar = 1;