From 3bcda4206fd38d6a5c3f2a28d7ba49efc0ae3188 Mon Sep 17 00:00:00 2001 From: Hans Zandbelt Date: Tue, 19 Sep 2023 11:34:49 +0100 Subject: [PATCH] fix performance issue with latin1 encoding when using OIDCPassClaimsAs latin1; bump to 2.4.14.4rc1 Signed-off-by: Hans Zandbelt --- ChangeLog | 4 ++++ configure.ac | 2 +- src/util.c | 16 +++++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75f6047e..da3fa472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +09/19/2023 +- fix performance issue with latin1 encoding when using OIDCPassClaimsAs latin1 +- bump to 2.4.14.4rc1 + 09/14/2023 - fix `OIDCRefreshAccessTokenBeforeExpiry` when using it with `logout_on_error` or `authenticate_on_error` see #1111; thanks @brandonk10 diff --git a/configure.ac b/configure.ac index bfb871df..7a9ff837 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mod_auth_openidc],[2.4.14.4rc0],[hans.zandbelt@openidc.com]) +AC_INIT([mod_auth_openidc],[2.4.14.4rc1],[hans.zandbelt@openidc.com]) AC_SUBST(NAMEVER, AC_PACKAGE_TARNAME()-AC_PACKAGE_VERSION()) diff --git a/src/util.c b/src/util.c index 6fbd29a3..409edf9e 100644 --- a/src/util.c +++ b/src/util.c @@ -2184,10 +2184,12 @@ static char* oidc_util_utf8_to_latin1(request_rec *r, const char *src) { char *dst = ""; unsigned int cp = 0; unsigned char ch; + int i = 0; if (src == NULL) return NULL; - while (*src != '\0') { - ch = (unsigned char) (*src); + dst = apr_pcalloc(r->pool, strlen(src) + 1); + while (src[i] != '\0') { + ch = (unsigned char) (src[i]); if (ch <= 0x7f) cp = ch; else if (ch <= 0xbf) @@ -2198,20 +2200,20 @@ static char* oidc_util_utf8_to_latin1(request_rec *r, const char *src) { cp = ch & 0x0f; else cp = ch & 0x07; - ++src; - if (((*src & 0xc0) != 0x80) && (cp <= 0x10ffff)) { + if (((src[i + 1] & 0xc0) != 0x80) && (cp <= 0x10ffff)) { if (cp <= 255) { - dst = apr_psprintf(r->pool, "%s%c", dst, (unsigned char)cp); + dst[i] = (unsigned char) cp; } else { // no encoding possible - dst = apr_psprintf(r->pool, "%s%c", dst, '?'); + dst[i] = '?'; } } + i++; } + dst[i] = '\0'; return dst; } - /* * set a HTTP header and/or environment variable to pass information to the application */