Skip to content

Commit 851aa6a

Browse files
committed
refactor NGINX port extraction; closes #49; thanks @anpin
and make it compatible with NGINX >= 1.27.0 Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 4f458d7 commit 851aa6a

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ reporting bugs, providing fixes, suggesting useful features or other:
1212
Mikael Broadfoot <https://github.com/broadfootmi>
1313
Robert Title <https://github.com/rtitle>
1414
may-day <https://github.com/may-day>
15+
Pavel Anpin <https://github.com/anpin>

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
05/31/2024
2+
- refactor NGINX port extraction so it works with NGINX >= 1.27.0; closes #49; thanks @anpin
3+
14
03/11/2024
25
- release 1.6.1
36

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ noinst_LTLIBRARIES = liboauth2_cache.la
8989
liboauth2_la_LIBADD += liboauth2_cache.la
9090
liboauth2_cache_la_SOURCES = src/cache.c
9191
liboauth2_cache_la_CPPFLAGS = $(AM_CPPFLAGS)
92-
liboauth2_cache_la_CFLAGS = @CURL_CFLAGS@ @CJOSE_CFLAGS@
92+
liboauth2_cache_la_CFLAGS = @CURL_CFLAGS@ @CJOSE_CFLAGS@ @PCRE2_CFLAGS@
9393

9494
if HAVE_LIBMEMCACHE
9595
liboauth2_cache_la_CPPFLAGS += -DHAVE_LIBMEMCACHE
@@ -120,7 +120,7 @@ liboauth2_apache_la_pkgconfigdir = $(libdir)/pkgconfig
120120
liboauth2_apache_la_pkgconfig_DATA = liboauth2_apache.pc
121121

122122
liboauth2_apache_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_APACHE
123-
liboauth2_apache_la_CFLAGS = @APACHE_CFLAGS@
123+
liboauth2_apache_la_CFLAGS = @APACHE_CFLAGS@ @PCRE2_CFLAGS@
124124
liboauth2_apache_la_LIBADD = liboauth2.la @APR_LIBS@ @JANSSON_LIBS@
125125

126126
includesub_HEADERS += \
@@ -141,7 +141,7 @@ liboauth2_nginx_la_pkgconfigdir = $(libdir)/pkgconfig
141141
liboauth2_nginx_la_pkgconfig_DATA = liboauth2_nginx.pc
142142

143143
liboauth2_nginx_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_NGINX
144-
liboauth2_nginx_la_CFLAGS = @NGINX_CFLAGS@
144+
liboauth2_nginx_la_CFLAGS = @NGINX_CFLAGS@ @PCRE2_CFLAGS@
145145
liboauth2_nginx_la_LIBADD = liboauth2.la @NGINX_LIBS@ @JANSSON_LIBS@
146146

147147
includesub_HEADERS += \

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([liboauth2],[1.6.1],[[email protected]])
1+
AC_INIT([liboauth2],[1.6.2dev],[[email protected]])
22

33
AM_INIT_AUTOMAKE([foreign no-define subdir-objects])
44
AC_CONFIG_MACRO_DIR([m4])

src/server/nginx.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,8 @@ static void _oauth2_nginx_host_copy(oauth2_nginx_request_context_t *ctx)
9999

100100
static void _oauth2_nginx_port_copy(oauth2_nginx_request_context_t *ctx)
101101
{
102-
char *v = NULL;
103-
int len = ctx->r->port_end - ctx->r->port_start;
104-
if (len > 0) {
105-
v = oauth2_strndup((const char *)ctx->r->port_start, len);
106-
oauth2_http_request_port_set(ctx->log, ctx->request,
107-
oauth2_parse_uint(NULL, v, 0));
108-
oauth2_mem_free(v);
109-
}
102+
in_port_t port = ngx_inet_get_port(ctx->r->connection->sockaddr);
103+
oauth2_http_request_port_set(ctx->log, ctx->request, (unsigned long)port);
110104
}
111105

112106
static void _oauth2_nginx_path_copy(oauth2_nginx_request_context_t *ctx)

0 commit comments

Comments
 (0)