]> git.sur5r.net Git - openldap/commitdiff
Added ldapsearch bad filter pattern check (ITS#4647)
authorKurt Zeilenga <kurt@openldap.org>
Fri, 25 Aug 2006 04:51:46 +0000 (04:51 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 25 Aug 2006 04:51:46 +0000 (04:51 +0000)
CHANGES
clients/tools/ldapsearch.c

diff --git a/CHANGES b/CHANGES
index 63c7959717415a79b0045ddb52f76a617a567a0f..73a6a470738efb14da657c768bc0525c57236aec 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
 OpenLDAP 2.3 Change Log
 
 OpenLDAP 2.3.28 Engineering
+       Added ldapsearch bad filter pattern check (ITS#4647)
 
 OpenLDAP 2.3.27 Release
        Fixed libldap dangling pointer issue (previous fix was broken) (ITS#4405)
index 513452fd2f1a4b93375ed94e6476ab8cea029ce6..5496fbf1ae0f43547937f19eb0caeb20251caf64 100644 (file)
@@ -611,12 +611,32 @@ main( int argc, char **argv )
        }
 
        if ( infile != NULL ) {
+               int percent = 0;
+       
                if ( infile[0] == '-' && infile[1] == '\0' ) {
                        fp = stdin;
                } else if (( fp = fopen( infile, "r" )) == NULL ) {
                        perror( infile );
                        return EXIT_FAILURE;
                }
+
+               for( i=0 ; filtpattern[i] ; i++ ) {
+                       if( filtpattern[i] == '%' ) {
+                               if( percent ) {
+                                       fprintf( stderr, _("Bad filter pattern \"%s\"\n"),
+                                               filtpattern );
+                                       return EXIT_FAILURE;
+                               }
+
+                               percent++;
+
+                               if( filtpattern[i+1] != 's' ) {
+                                       fprintf( stderr, _("Bad filter pattern \"%s\"\n"),
+                                               filtpattern );
+                                       return EXIT_FAILURE;
+                               }
+                       }
+               }
        }
 
        if ( tmpdir == NULL ) {