Skip to content

Commit c06ebff

Browse files
committed
code: avoid potential crash on non-conformant literal IPv6 adresses
in oidc_util_current_url_host Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 74db443 commit c06ebff

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- code: declare memcache members as int so they can be set to OIDC_CONFIG_POS_INT_UNSET without warning
55
- code: declare introspection_endpoint_method member as int so it can be set to OIDC_CONFIG_POS_INT_UNSET without warning
66
- code: check return value of oidc_get_provider_from_session and oidc_refresh_token_grant in logout.c
7+
- code: avoid potential crash on non-conformant literal IPv6 adresses in oidc_util_current_url_host
78

89
12/15/2024
910
- add Coverity Github action

src/util.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,6 @@ static const char *oidc_get_current_url_port(const request_rec *r, const char *s
767767
const char *oidc_util_current_url_host(request_rec *r, oidc_hdr_x_forwarded_t x_forwarded_headers) {
768768
const char *host_str = NULL;
769769
char *p = NULL;
770-
char *i = NULL;
771770

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

782781
if (host_str[0] == '[') {
783-
i = strchr(host_str, ']');
784-
p = strchr(i, OIDC_CHAR_COLON);
782+
p = strchr(host_str, ']');
783+
if (p)
784+
p = strchr(p, OIDC_CHAR_COLON);
785785
} else {
786786
p = strchr(host_str, OIDC_CHAR_COLON);
787787
}
@@ -792,6 +792,7 @@ const char *oidc_util_current_url_host(request_rec *r, oidc_hdr_x_forwarded_t x_
792792
/* no Host header, HTTP 1.0 */
793793
host_str = ap_get_server_name(r);
794794
}
795+
795796
return host_str;
796797
}
797798

0 commit comments

Comments
 (0)