Commit 774b81b6 authored by Justin Erenkrantz's avatar Justin Erenkrantz
Browse files

mod_auth_ldap: Handle the inconsistent way in which the MS LDAP library

handles special characters.

MFC: 105379
PR: 24437
Submitted by: Jess Holle
Reviewed by: minfrin, wrowe, jim


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@151272 13f79535-47bb-0310-9956-ffa450edef68
parent b47f259b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.53
  *) mod_auth_ldap: Handle the inconsistent way in which the MS LDAP
     library handles special characters.  PR 24437.  [Jess Holle]
  *) Win32 MPM: Correct typo in debugging output.  [William Rowe]
  *) conf: Remove AddDefaultCharset from the default configuration because
+34 −6
Original line number Diff line number Diff line
@@ -222,19 +222,47 @@ void mod_auth_ldap_build_filter(char *filtbuf,
     * LDAP filter metachars are escaped.
     */
    filtbuf_end = filtbuf + FILTER_LENGTH - 1;
    for (p = user, q=filtbuf + strlen(filtbuf);
         *p && q < filtbuf_end; *q++ = *p++) {
#if APR_HAS_MICROSOFT_LDAPSDK
        /* Note: The Microsoft SDK escapes for us, so is not necessary */
    for (p = user, q=filtbuf + strlen(filtbuf);
         *p && q < filtbuf_end; ) {
        if (strchr("*()\\", *p) != NULL) {
            if ( q + 3 >= filtbuf_end)
              break;  /* Don't write part of escape sequence if we can't write all of it */
            *q++ = '\\';
            switch ( *p++ )
            {
              case '*':
                *q++ = '2';
                *q++ = 'a';
                break;
              case '(':
                *q++ = '2';
                *q++ = '8';
                break;
              case ')':
                *q++ = '2';
                *q++ = '9';
                break;
              case '\\':
                *q++ = '5';
                *q++ = 'c';
                break;
           }
        }
        else
            *q++ = *p++;
    }
#else
    for (p = user, q=filtbuf + strlen(filtbuf);
         *p && q < filtbuf_end; *q++ = *p++) {
        if (strchr("*()\\", *p) != NULL) {
            *q++ = '\\';
            if (q >= filtbuf_end) {
              break;
            }
        }
#endif
    }
#endif
    *q = '\0';

    /*