From a7e0c6cd2e8631feee42a4e80541e68caf37de00 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 1 Feb 2011 05:24:53 +0000 Subject: [PATCH] ITS#6755 pagedresults loop was accessing a closed FILE*. --- clients/tools/ldapsearch.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; } } -- 2.39.5