From 106a4b90aa9ab04ef78993ebb29a66ab1669770a Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 7 Feb 2014 00:31:23 -0800 Subject: [PATCH] More for ITS#4365 refix CR/LF handling Was rejecting "-\r\n" in input LDIF --- libraries/libldap/ldif.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/libldap/ldif.c b/libraries/libldap/ldif.c index 8de9f2a256..dbdfc5c47a 100644 --- a/libraries/libldap/ldif.c +++ b/libraries/libldap/ldif.c @@ -853,11 +853,16 @@ ldif_read_record( line[++len] = '\0'; } + /* Squash \r\n to \n */ + if ( len > 1 && line[len-2] == '\r' ) { + len--; + line[len-1] = '\n'; + } + if ( last_ch == '\n' ) { (*lno)++; - if ( line[0] == '\n' || - ( line[0] == '\r' && line[1] == '\n' )) { + if ( line[0] == '\n' ) { if ( !found_entry ) { lcur = 0; top_comment = 0; @@ -887,10 +892,6 @@ ldif_read_record( len--; line[len] = '\0'; } - if ( line[len-1] == '\r' ) { - len--; - line[len] = '\0'; - } ptr = line + STRLENOF("include:"); while (isspace((unsigned char) *ptr)) ptr++; -- 2.39.5