Blame SOURCES/0021-fix-for-cve-2017-2668-simple-return-text-if-suffix-n.patch

74ca47
From ea60248d99abb8fed9f7a2b1ab7325c5523b8562 Mon Sep 17 00:00:00 2001
c9e5da
From: Ludwig Krispenz <lkrispen@redhat.com>
c9e5da
Date: Mon, 3 Apr 2017 09:32:20 +0200
c9e5da
Subject: [PATCH] fix for cve 2017-2668 - simple return text if suffix not
c9e5da
 found
c9e5da
c9e5da
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436575
c9e5da
c9e5da
Signed-off-by: Mark Reynolds <mreynolds@redhat.com>
c9e5da
---
c9e5da
 ldap/servers/slapd/defbackend.c | 75 ++---------------------------------------
c9e5da
 1 file changed, 2 insertions(+), 73 deletions(-)
c9e5da
c9e5da
diff --git a/ldap/servers/slapd/defbackend.c b/ldap/servers/slapd/defbackend.c
74ca47
index 6fd74a3..6cd2c04 100644
c9e5da
--- a/ldap/servers/slapd/defbackend.c
c9e5da
+++ b/ldap/servers/slapd/defbackend.c
74ca47
@@ -166,50 +166,7 @@ defbackend_abandon( Slapi_PBlock *pb )
c9e5da
 }
c9e5da
 
c9e5da
 
c9e5da
-#define DEFBE_NO_SUCH_SUFFIX "No such suffix"
c9e5da
-/*
c9e5da
- * Generate a "No such suffix" return text
c9e5da
- * Example:
c9e5da
- *   cn=X,dc=bogus,dc=com ==> "No such suffix (dc=bogus,dc=com)" 
c9e5da
- *     if the last rdn starts with "dc=", print all last dc= rdn's.
c9e5da
- *   cn=X,cn=bogus ==> "No such suffix (cn=bogus)"
c9e5da
- *     otherwise, print the very last rdn.
c9e5da
- *   cn=X,z=bogus ==> "No such suffix (x=bogus)"
c9e5da
- *     it is true even if it is an invalid rdn.
c9e5da
- *   cn=X,bogus ==> "No such suffix (bogus)"
c9e5da
- *     another example of invalid rdn.
c9e5da
- */
c9e5da
-static void
c9e5da
-_defbackend_gen_returntext(char *buffer, size_t buflen, char **dns)
c9e5da
-{
c9e5da
-    int dnidx;
c9e5da
-    int sidx;
c9e5da
-    struct suffix_repeat {
c9e5da
-        char *suffix;
c9e5da
-        int size;
c9e5da
-    } candidates[] = {
c9e5da
-        {"dc=", 3}, /* dc could be repeated.  otherwise the last rdn is used. */
c9e5da
-        {NULL, 0}
c9e5da
-    };
c9e5da
-    PR_snprintf(buffer, buflen, "%s (", DEFBE_NO_SUCH_SUFFIX);
c9e5da
-    for (dnidx = 0; dns[dnidx]; dnidx++) ; /* finding the last */
c9e5da
-    dnidx--; /* last rdn */
c9e5da
-    for (sidx = 0; candidates[sidx].suffix; sidx++) {
c9e5da
-        if (!PL_strncasecmp(dns[dnidx], candidates[sidx].suffix, candidates[sidx].size)) {
c9e5da
-            while (!PL_strncasecmp(dns[--dnidx], candidates[sidx].suffix, candidates[sidx].size)) ;
c9e5da
-            PL_strcat(buffer, dns[++dnidx]); /* the first "dn=", e.g. */
c9e5da
-            for (++dnidx; dns[dnidx]; dnidx++) {
c9e5da
-                PL_strcat(buffer, ",");
c9e5da
-                PL_strcat(buffer, dns[dnidx]);
c9e5da
-            }
c9e5da
-            PL_strcat(buffer, ")");
c9e5da
-            return; /* finished the task */
c9e5da
-        }
c9e5da
-    }
c9e5da
-    PL_strcat(buffer, dns[dnidx]);
c9e5da
-    PL_strcat(buffer, ")");
c9e5da
-    return;
c9e5da
-}
c9e5da
+#define DEFBE_NO_SUCH_SUFFIX "No suffix for bind dn found"
c9e5da
 
c9e5da
 static int
c9e5da
 defbackend_bind( Slapi_PBlock *pb )
74ca47
@@ -231,36 +188,8 @@ defbackend_bind( Slapi_PBlock *pb )
c9e5da
         slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsAnonymousBinds);
c9e5da
         rc = SLAPI_BIND_ANONYMOUS;
c9e5da
     } else {
c9e5da
-        Slapi_DN *sdn = NULL;
c9e5da
-        char *suffix = NULL;
c9e5da
-        char **dns = NULL;
c9e5da
-        
c9e5da
-        if (pb->pb_op) {
c9e5da
-            sdn = operation_get_target_spec(pb->pb_op);
c9e5da
-            if (sdn) {
c9e5da
-                dns = slapi_ldap_explode_dn(slapi_sdn_get_dn(sdn), 0);
c9e5da
-                if (dns) {
c9e5da
-                    size_t dnlen = slapi_sdn_get_ndn_len(sdn);
c9e5da
-                    size_t len = dnlen + sizeof(DEFBE_NO_SUCH_SUFFIX) + 4;
c9e5da
-                    suffix = slapi_ch_malloc(len);
c9e5da
-                    if (dnlen) {
c9e5da
-                        _defbackend_gen_returntext(suffix, len, dns);
c9e5da
-                    } else {
c9e5da
-                        PR_snprintf(suffix, len, "%s", DEFBE_NO_SUCH_SUFFIX);
c9e5da
-                    }
c9e5da
-                }
c9e5da
-            }
c9e5da
-        }
c9e5da
-        if (suffix) {
c9e5da
-            slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, suffix);
c9e5da
-        } else {
c9e5da
-            slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, DEFBE_NO_SUCH_SUFFIX);
c9e5da
-        }
c9e5da
+        slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, DEFBE_NO_SUCH_SUFFIX);
c9e5da
         send_ldap_result(pb, LDAP_INVALID_CREDENTIALS, NULL, "", 0, NULL);
c9e5da
-        if (dns) {
c9e5da
-            slapi_ldap_value_free(dns);
c9e5da
-        }
c9e5da
-        slapi_ch_free_string(&suffix);
c9e5da
         rc = SLAPI_BIND_FAIL;
c9e5da
     }
c9e5da
 
c9e5da
-- 
c9e5da
2.9.3
c9e5da