mrc0mmand / rpms / openldap

Forked from rpms/openldap 3 years ago
Clone
Blob Blame History Raw
commit aa66d539543de0ad884f1b8e38948ecd946bf47a
Author: Howard Chu <hyc@openldap.org>
Date:   Mon Dec 15 14:36:55 2014 +0000

    ITS#8003 fix off-by-one in LDIF length
    
    must account for leading space when counting total number of lines

diff --git a/include/ldif.h b/include/ldif.h
index f638ef9..69bb0c9 100644
--- a/include/ldif.h
+++ b/include/ldif.h
@@ -52,12 +52,12 @@ LDAP_LDIF_V (int) ldif_debug;
  */
 #define LDIF_SIZE_NEEDED(nlen,vlen) \
     ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
-    + ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
+    + ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (LDIF_LINE_WIDTH-1) * 2 ))
 
 #define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
     ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
-    + ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH ) * 2 ) : \
-	((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap) * 2 ))))
+    + ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH-1 ) * 2 ) : \
+	((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap-1) * 2 ))))
 
 LDAP_LDIF_F( int )
 ldif_parse_line LDAP_P((