diff --git a/libraries/libldap/ldif.c b/libraries/libldap/ldif.c index 7ca5e32cf9..900a979607 100644 --- a/libraries/libldap/ldif.c +++ b/libraries/libldap/ldif.c @@ -796,6 +796,7 @@ ldif_read_record( * back to a previous file. (return from an include) */ while ( feof( lfp->fp )) { +pop: if ( lfp->prev ) { LDIFFP *tmp = lfp->prev; fclose( lfp->fp ); @@ -808,6 +809,10 @@ ldif_read_record( } if ( !stop ) { if ( fgets( line, sizeof( line ), lfp->fp ) == NULL ) { + if ( !found_entry && !ferror( lfp->fp ) ) { + /* ITS#9811 Reached the end looking for an entry, try again */ + goto pop; + } stop = 1; len = 0; } else {