Original Reporter: aliu
Environment: Not Specified
Version: 1.3.1
Migrated From: https://jira.spring.io//browse/LDAP-233
org.springframework.ldap.ldif.parser.LdifParser has a corner case in getRecord(), where an input file with no valid LDIF records will cause an infinite loop. This is because the main switch statement will always hit the default (do nothing) case, and the while loop does not have a condition to terminate at EOF.
This can be fixed by having the record variable initialized to null, and delaying creation of a new LdapAttributes object to inside of the switch's NewRecord case, and then adding a check at the end of the while loop for a null read result.
This allows us to differentiate between files where an LDIF entry is malformed vs cases where no entry was found at all. See attached for proposed fix.
An easy way to test this code is to feed an empty file into the parser.
Original Reporter: aliu Environment: Not Specified Version: 1.3.1 Migrated From: https://jira.spring.io//browse/LDAP-233 org.springframework.ldap.ldif.parser.LdifParser has a corner case in getRecord(), where an input file with no valid LDIF records will cause an infinite loop. This is because the main switch statement will always hit the default (do nothing) case, and the while loop does not have a condition to terminate at EOF.
This can be fixed by having the record variable initialized to null, and delaying creation of a new LdapAttributes object to inside of the switch's NewRecord case, and then adding a check at the end of the while loop for a null read result.
This allows us to differentiate between files where an LDIF entry is malformed vs cases where no entry was found at all. See attached for proposed fix.
An easy way to test this code is to feed an empty file into the parser.