cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] LDAP: fix wrong encoded attributes in query result

From: Alfred Gebert <alfred.gebert_at_gmail.com>
Date: Fri, 5 Nov 2010 15:31:19 +0100

If the query result has a binary attribute, the binary attribute
is base64 encoded. But all following non binary attributes are
also base64 encoded which is wrong.

This is a test (LDAP server is public).

curl ldap://x500.bund.de:389/o=Bund,c=DE?userCertificate,certificateSerialNumber?sub?cn=*Woehleke*

Wrong content of attribute certificateSerialNumber with curl 7.21.2
and curl head:

DN: cn=Woehleke Claudia,l=init,ou=Service,o=Bund,c=DE
        userCertificate;binary:: MIIEbDCCA1SgAw ...
           (removed other characters)

        certificateSerialNumber:: MjIwNjQ=

Correct result with curl 7.20.1 and with this patch:

DN: cn=Woehleke Claudia,l=init,ou=Service,o=Bund,c=DE
        userCertificate;binary:: MIIEbDCCA1SgAw ...
           (removed other characters)

        certificateSerialNumber: 22064

---
 lib/openldap.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/openldap.c b/lib/openldap.c
index 4d5db4a..4ad796e 100644
--- a/lib/openldap.c
+++ b/lib/openldap.c
@@ -497,8 +497,11 @@ static ssize_t ldap_recv(struct connectdata
*conn, int sockindex, char *buf,
       if (bv.bv_val == NULL) break;
-      if (bv.bv_len > 7 && !strncmp(bv.bv_val + bv.bv_len - 7, ";binary", 7))
+      if (bv.bv_len > 7 && !strncmp(bv.bv_val + bv.bv_len - 7, ";binary", 7)) {
         binary = 1;
+      } else {
+        binary = 0;
+      }
       for (i=0; bvals[i].bv_val != NULL; i++) {
         int binval = 0;
--
1.6.4.2
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-05