ITS#4647: error on bad filter patterns

This commit is contained in:
Kurt Zeilenga 2006-08-24 03:15:57 +00:00
parent d3e288dffe
commit e2f4ca480d
2 changed files with 27 additions and 3 deletions

View file

@ -676,12 +676,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 ) {

View file

@ -165,9 +165,13 @@ must be compiled with LDAP_DEBUG defined for this option to have any effect.
.BI \-f \ file
Read a series of lines from \fIfile\fP, performing one LDAP search for
each line. In this case, the \fIfilter\fP given on the command line
is treated as a pattern where the first occurrence of \fB%s\fP is
replaced with a line from \fIfile\fP. If \fIfile\fP is a single \fI-\fP
character, then the lines are read from standard input.
is treated as a pattern where the first and only occurrence of \fB%s\fP
is replaced with a line from \fIfile\fP. Any other occurence of the
the \fB%\fP character in the pattern will be regarded as an error.
Where it is desired that the search filter include a \fB%\fP character,
the character should be encoded as \fB\\25\fP (see RFC 4515).
If \fIfile\fP is a single
\fI-\fP character, then the lines are read from standard input.
.TP
.B \-x
Use simple authentication instead of SASL.