ldap(1) search off by 1 in LDIF

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ldap(1) search off by 1 in LDIF

Martijn van Duren-8
There's two (compounding) off by ones in ldap(1), which drops characters
on the start of each LDIF continuation line.
Diff below fixes this.

OK?

martijn@

Index: ldapclient.c
===================================================================
RCS file: /cvs/src/usr.bin/ldap/ldapclient.c,v
retrieving revision 1.3
diff -u -p -r1.3 ldapclient.c
--- ldapclient.c 3 Jul 2018 10:10:09 -0000 1.3
+++ ldapclient.c 19 Oct 2018 10:56:01 -0000
@@ -440,9 +440,11 @@ ldapc_printattr(struct ldapc *ldap, cons
  /* Wrap lines */
  for (outlen = 0, inlen = strlen(p);
     outlen < inlen;
-    outlen += LDIF_LINELENGTH) {
+    outlen += LDIF_LINELENGTH - 1) {
  if (outlen)
  putchar(' ');
+ if (outlen > LDIF_LINELENGTH)
+ outlen--;
  /* max. line length - newline - optional indent */
  left = MIN(inlen - outlen, outlen ?
     LDIF_LINELENGTH - 2 :