]> git.sur5r.net Git - openldap/commitdiff
use /-* for all parents; ignore /-0; check syntax; better parsing
authorPierangelo Masarati <ando@openldap.org>
Mon, 10 Sep 2007 22:29:10 +0000 (22:29 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 10 Sep 2007 22:29:10 +0000 (22:29 +0000)
servers/slapd/sets.c

index e2943ca4a8ec4f24f3c5c865cab718d4f33eace7..dc1bc858434a29dc802156c1bbd2e89589f834de 100644 (file)
@@ -650,27 +650,33 @@ slap_set_filter( SLAP_SET_GATHER gatherer,
 
                case '-':
                        if ( ( SF_TOP() == (void *)'/' )
-                                       && ( *filter >= '0' || *filter <= '9' ) )
+                               && ( *filter == '*' || ASCII_DIGIT( *filter ) ) )
                        {
-                               int parent = 0;
-                               int count = 1;
-                               int i;
-                               for ( len = 1;
-                                               ( c = filter[ len ] )
-                                                       && ( c >= '0' && c <= '9' );
-                                               len++ )
-                                       /* count */ ;
-                               for ( i = len ; i > 0 ; i-- ) {
-                                       parent += (int)( filter[ i - 1 ] - '0' ) * count;
-                                       count *= 10;
-                               }
                                SF_POP();
-                               if ( parent == 0 ) {
+
+                               if ( *filter == '*' ) {
                                        set = set_parents( cp, SF_POP() );
+                                       filter++;
+
                                } else {
-                                       set = set_parent( cp, SF_POP(), parent );
+                                       char *next = NULL;
+                                       long parent = strtol( filter, &next, 10 );
+
+                                       if ( next == filter ) {
+                                               SF_ERROR( syntax );
+                                       }
+
+                                       set = SF_POP();
+                                       if ( parent != 0 ) {
+                                               set = set_parent( cp, set, parent );
+                                       }
+                                       filter = next;
+                               }
+
+                               if ( set == NULL ) {
+                                       SF_ERROR( memory );
                                }
-                               filter += len;
+
                                SF_PUSH( set );
                                set = NULL;
                                break;