Skip to content

Commit 4e66d87

Browse files
committed
refactor log suppress handling: avoid Forwarded matching X-Forwarded-*
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent a96e0f1 commit 4e66d87

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/cfg/cfg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,13 @@ OIDC_CFG_MEMBER_FUNC_TYPE_GET(x_forwarded_headers, oidc_hdr_x_forwarded_t, OIDC_
446446

447447
static void oidc_check_x_forwarded_hdr(request_rec *r, const apr_byte_t x_forwarded_headers, const apr_byte_t hdr_type,
448448
const char *hdr_str, const char *(hdr_func)(const request_rec *r)) {
449-
const char *env_var = apr_table_get(r->subprocess_env, OIDC_CHECK_X_FORWARDED_HDR_LOG_DISABLE);
449+
apr_byte_t suppress = oidc_util_spaced_string_contains(
450+
r->pool, apr_table_get(r->subprocess_env, OIDC_CHECK_X_FORWARDED_HDR_LOG_DISABLE), hdr_str);
450451
if (hdr_func(r)) {
451-
if (!(x_forwarded_headers & hdr_type) && (_oidc_strstr(env_var, hdr_str) == NULL))
452+
if (!(x_forwarded_headers & hdr_type) && !suppress)
452453
oidc_warn(r, "header %s received but %s not configured for it", hdr_str, OIDCXForwardedHeaders);
453454
} else {
454-
if ((x_forwarded_headers & hdr_type) && (_oidc_strstr(env_var, hdr_str) == NULL))
455+
if ((x_forwarded_headers & hdr_type) && !suppress)
455456
oidc_warn(r, "%s configured for header %s but not found in request", OIDCXForwardedHeaders,
456457
hdr_str);
457458
}

src/util/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ apr_byte_t oidc_util_spaced_string_equals(apr_pool_t *pool, const char *a, const
380380
* see if a particular value is part of a space separated value
381381
*/
382382
apr_byte_t oidc_util_spaced_string_contains(apr_pool_t *pool, const char *str, const char *match) {
383+
if ((str == NULL) || (match == NULL))
384+
return FALSE;
383385
apr_hash_t *ht = oidc_util_spaced_string_to_hashtable(pool, str);
384386
return (apr_hash_get(ht, match, APR_HASH_KEY_STRING) != NULL);
385387
}

0 commit comments

Comments
 (0)