Skip to content

Commit

Permalink
code: avoid potential crash on non-conformant literal IPv6 adresses
Browse files Browse the repository at this point in the history
in oidc_util_current_url_host

Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Dec 16, 2024
1 parent 74db443 commit c06ebff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- code: declare memcache members as int so they can be set to OIDC_CONFIG_POS_INT_UNSET without warning
- code: declare introspection_endpoint_method member as int so it can be set to OIDC_CONFIG_POS_INT_UNSET without warning
- code: check return value of oidc_get_provider_from_session and oidc_refresh_token_grant in logout.c
- code: avoid potential crash on non-conformant literal IPv6 adresses in oidc_util_current_url_host

12/15/2024
- add Coverity Github action
Expand Down
7 changes: 4 additions & 3 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,6 @@ static const char *oidc_get_current_url_port(const request_rec *r, const char *s
const char *oidc_util_current_url_host(request_rec *r, oidc_hdr_x_forwarded_t x_forwarded_headers) {
const char *host_str = NULL;
char *p = NULL;
char *i = NULL;

if (x_forwarded_headers & OIDC_HDR_FORWARDED)
host_str = oidc_http_hdr_forwarded_get(r, "host");
Expand All @@ -780,8 +779,9 @@ const char *oidc_util_current_url_host(request_rec *r, oidc_hdr_x_forwarded_t x_
host_str = apr_pstrdup(r->pool, host_str);

if (host_str[0] == '[') {
i = strchr(host_str, ']');
p = strchr(i, OIDC_CHAR_COLON);
p = strchr(host_str, ']');
if (p)
p = strchr(p, OIDC_CHAR_COLON);
} else {
p = strchr(host_str, OIDC_CHAR_COLON);
}
Expand All @@ -792,6 +792,7 @@ const char *oidc_util_current_url_host(request_rec *r, oidc_hdr_x_forwarded_t x_
/* no Host header, HTTP 1.0 */
host_str = ap_get_server_name(r);
}

return host_str;
}

Expand Down

0 comments on commit c06ebff

Please sign in to comment.