]> git.sur5r.net Git - openldap/commitdiff
More for ITS#4365 refix CR/LF handling
authorHoward Chu <hyc@openldap.org>
Fri, 7 Feb 2014 08:31:23 +0000 (00:31 -0800)
committerHoward Chu <hyc@openldap.org>
Fri, 7 Feb 2014 08:31:23 +0000 (00:31 -0800)
Was rejecting "-\r\n" in input LDIF

libraries/libldap/ldif.c

index 8de9f2a2567aec2ecedf889c4f8abcc08eaa9e58..dbdfc5c47a7a2d9c5be7e62fbb4fec032cfddcd7 100644 (file)
@@ -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++;