mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 07:09:34 -05:00
ITS#6947 Handle missing '\n' termination in LDIF input
This commit is contained in:
parent
6f43600731
commit
65e163d268
1 changed files with 9 additions and 4 deletions
|
|
@ -842,11 +842,16 @@ ldif_read_record(
|
||||||
|
|
||||||
if ( fgets( line, sizeof( line ), lfp->fp ) == NULL ) {
|
if ( fgets( line, sizeof( line ), lfp->fp ) == NULL ) {
|
||||||
stop = 1;
|
stop = 1;
|
||||||
/* Add \n in case the file does not end with newline */
|
len = 0;
|
||||||
line[0] = '\n';
|
} else {
|
||||||
line[1] = '\0';
|
|
||||||
}
|
|
||||||
len = strlen( line );
|
len = strlen( line );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( len == 0 || line[len-1] != '\n' ) {
|
||||||
|
/* Add \n in case the line/file does not end with newline */
|
||||||
|
line[len] = '\n';
|
||||||
|
line[++len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if ( last_ch == '\n' ) {
|
if ( last_ch == '\n' ) {
|
||||||
(*lno)++;
|
(*lno)++;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue