]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapsearch.c
ITS#6755
[openldap] / clients / tools / ldapsearch.c
index 4e4f893b8f2632cc210ef4858a213d517fb68f03..1689f61c1582377300a08f54cfdd8811228c6005 100644 (file)
@@ -908,6 +908,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
@@ -1249,6 +1258,7 @@ getNextPage:
                }
                if ( fp != stdin ) {
                        fclose( fp );
+                       fp = NULL;
                }
        }