Blame SOURCES/0022-replace-potentially-harmful-backslashes-with-forward.patch

569f44
From 466f470265554e0e3ae27a6d82375456d2c133e6 Mon Sep 17 00:00:00 2001
569f44
From: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
569f44
Date: Thu, 22 Jul 2021 15:32:12 +0200
569f44
Subject: [PATCH 3/4] replace potentially harmful backslashes with forward
569f44
 slashes when validating redirection URLs
569f44
569f44
(cherry picked from commit 69cb206225c749b51db980d44dc268eee5623f2b)
569f44
---
569f44
 src/mod_auth_openidc.c | 12 +++++++++++-
569f44
 1 file changed, 11 insertions(+), 1 deletion(-)
569f44
569f44
diff --git a/src/mod_auth_openidc.c b/src/mod_auth_openidc.c
569f44
index 68fbca5..c96af75 100644
569f44
--- a/src/mod_auth_openidc.c
569f44
+++ b/src/mod_auth_openidc.c
569f44
@@ -2687,12 +2687,22 @@ static int oidc_handle_logout_request(request_rec *r, oidc_cfg *c,
569f44
 	return HTTP_MOVED_TEMPORARILY;
569f44
 }
569f44
 
569f44
+
569f44
+#define OIDC_MAX_URL_LENGTH DEFAULT_LIMIT_REQUEST_LINE * 2
569f44
+
569f44
 static apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c,
569f44
-		const char *url, apr_byte_t restrict_to_host, char **err_str,
569f44
+		const char *redirect_to_url, apr_byte_t restrict_to_host, char **err_str,
569f44
 		char **err_desc) {
569f44
 	apr_uri_t uri;
569f44
 	const char *c_host = NULL;
569f44
 	apr_hash_index_t *hi = NULL;
569f44
+	size_t i = 0;
569f44
+	char *url = apr_pstrndup(r->pool, redirect_to_url, OIDC_MAX_URL_LENGTH);
569f44
+
569f44
+	// replace potentially harmful backslashes with forward slashes
569f44
+	for (i = 0; i < strlen(url); i++)
569f44
+		if (url[i] == '\\')
569f44
+			url[i] = '/';
569f44
 
569f44
 	if (apr_uri_parse(r->pool, url, &uri) != APR_SUCCESS) {
569f44
 		*err_str = apr_pstrdup(r->pool, "Malformed URL");
569f44
-- 
569f44
2.31.1
569f44