]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
lib/ldap/util: fix double-backslash normalise_dn outputs extra char; fix fr_ldap_comm...
authorAlexander Bainbridge-Sedivy <alex.bainbridge@inkbridge.io>
Thu, 7 May 2026 19:16:15 +0000 (15:16 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 27 May 2026 17:38:31 +0000 (13:38 -0400)
src/lib/ldap/util.c

index 92b570cb9302b70825f909ce1ded121b28eb250c..fe4986ced7c32fae48d7da6a3c708692ceb76d3f 100644 (file)
@@ -568,12 +568,13 @@ size_t fr_ldap_util_normalise_dn(char *out, char const *in)
                        char c = '\0';
 
                        /*
-                        *      Double backslashes get processed specially
+                        *      Double backslashes get passed through as-is.
+                        *      Copy both and let the for loop advance past the second.
                         */
                        if (p[1] == '\\') {
-                               p += 1;
                                *o++ = p[0];
                                *o++ = p[1];
+                               p++;
                                continue;
                        }
 
@@ -622,7 +623,7 @@ size_t fr_ldap_common_dn(char const *full, char const *part)
 
        if ((f_len < p_len) || !f_len) return -1;
 
-       for (i = 0; i < p_len; i++) if (part[p_len - i] != full[f_len - i]) return -1;
+       for (i = 0; i < p_len; i++) if (part[p_len - 1 - i] != full[f_len - 1 - i]) return -1;
 
        return f_len - p_len;
 }