Ignore:
Timestamp:
Mar 7, 2008, 7:21:43 PM (14 years ago)
Author:
andersk
Message:
Use built-in ldap_bv2escaped_filter_value instead of a custom escaping
function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/common/oursrc/httpdmods/mod_vhost_ldap.c

    r680 r688  
    420420};
    421421
    422 char *mod_vhost_ldap_escape(apr_pool_t *p, const char *source)
    423 {
    424     char *target = apr_palloc(p, 3 * strlen(source) + 1);
    425     char *result = target;
    426     for (; *source; source++) {
    427         switch (*source) {
    428             case '*': case '(': case ')': case '\\':
    429                 sprintf(target, "\\%02hhx", *source);
    430                 target += 3;
    431                 break;
    432             default:
    433                 *target++ = *source;
    434                 break;
    435         }
    436     }
    437     *target = '\0';
    438     return result;
    439 }
    440 
    441422#define FILTER_LENGTH MAX_STRING_LEN
    442423static int mod_vhost_ldap_translate_name(request_rec *r)
     
    456437    const char *dn = NULL;
    457438    char *cgi;
    458     const char *hostname = NULL, *s_hostname = NULL;
     439    const char *hostname = NULL;
    459440    int is_fallback = 0;
    460441
     
    484465
    485466    hostname = r->hostname;
    486     if (hostname == NULL)
     467    if (hostname == NULL || hostname[0] == '\0')
    487468        goto null;
    488469
     
    492473                   "[mod_vhost_ldap.c]: translating %s", r->uri);
    493474
    494     s_hostname = mod_vhost_ldap_escape(r->pool, hostname);
    495     apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(|(apacheServerName=%s)(apacheServerAlias=%s)))", conf->filter, s_hostname, s_hostname);
     475    struct berval hostnamebv, shostnamebv;
     476    ber_str2bv(hostname, 0, 0, &hostnamebv);
     477    if (ldap_bv2escaped_filter_value(&hostnamebv, &shostnamebv) != 0)
     478        goto null;
     479    apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(|(apacheServerName=%s)(apacheServerAlias=%s)))", conf->filter, shostnamebv.bv_val, shostnamebv.bv_val);
     480    ber_memfree(shostnamebv.bv_val);
    496481
    497482    result = util_ldap_cache_getuserdn(r, ldc, conf->url, conf->basedn, conf->scope,
Note: See TracChangeset for help on using the changeset viewer.