]> git.sur5r.net Git - openldap/commitdiff
ITS#6755 pagedresults loop was accessing a closed FILE*.
authorHoward Chu <hyc@openldap.org>
Tue, 1 Feb 2011 05:24:53 +0000 (05:24 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 1 Feb 2011 05:24:53 +0000 (05:24 +0000)
clients/tools/ldapsearch.c

index ec3208241b80e138e64ab6a0e337d2d3c026ac08..494898a762f35f7eb5fe97f2768d25c6579090dd 100644 (file)
@@ -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;
                }
        }