Changeset 688 for server/common/oursrc/httpdmods
- Timestamp:
- Mar 7, 2008, 7:21:43 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/common/oursrc/httpdmods/mod_vhost_ldap.c
r680 r688 420 420 }; 421 421 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 441 422 #define FILTER_LENGTH MAX_STRING_LEN 442 423 static int mod_vhost_ldap_translate_name(request_rec *r) … … 456 437 const char *dn = NULL; 457 438 char *cgi; 458 const char *hostname = NULL , *s_hostname = NULL;439 const char *hostname = NULL; 459 440 int is_fallback = 0; 460 441 … … 484 465 485 466 hostname = r->hostname; 486 if (hostname == NULL )467 if (hostname == NULL || hostname[0] == '\0') 487 468 goto null; 488 469 … … 492 473 "[mod_vhost_ldap.c]: translating %s", r->uri); 493 474 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); 496 481 497 482 result = util_ldap_cache_getuserdn(r, ldc, conf->url, conf->basedn, conf->scope,
Note: See TracChangeset
for help on using the changeset viewer.