From: Howard Chu Date: Tue, 1 Feb 2011 05:24:53 +0000 (+0000) Subject: ITS#6755 pagedresults loop was accessing a closed FILE*. X-Git-Tag: MIGRATION_CVS2GIT~147 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a7e0c6cd2e8631feee42a4e80541e68caf37de00;p=openldap ITS#6755 pagedresults loop was accessing a closed FILE*. --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index ec3208241b..494898a762 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -918,6 +918,15 @@ main( int argc, char **argv ) tool_bind( ld ); getNextPage: + /* fp may have been closed, need to reopen if code jumps + * back here to getNextPage. + */ + if ( !fp && infile ) { + if (( fp = fopen( infile, "r" )) == NULL ) { + perror( infile ); + return EXIT_FAILURE; + } + } save_nctrls = nctrls; i = nctrls; if ( nctrls > 0 @@ -1259,6 +1268,7 @@ getNextPage: } if ( fp != stdin ) { fclose( fp ); + fp = NULL; } }