From aeca252d9d47649b07757b07cab70f4e116cf535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Wed, 28 Jun 2023 10:57:09 -0400 Subject: [PATCH] Bump lua-resty-core version to 0.1.27 and lua-nginx-module version to 0.10.25 --- src/deps/clone.sh | 14 +++--- .../src/api/ngx_http_lua_api.h | 2 +- .../src/ngx_http_lua_accessby.c | 6 +-- .../src/ngx_http_lua_bodyfilterby.c | 4 +- .../src/ngx_http_lua_common.h | 2 +- .../src/ngx_http_lua_contentby.c | 4 +- .../src/ngx_http_lua_directive.c | 4 +- .../src/ngx_http_lua_headerfilterby.c | 4 +- .../src/ngx_http_lua_rewriteby.c | 6 +-- .../src/ngx_http_lua_server_rewriteby.c | 4 +- .../src/ngx_http_lua_socket_udp.c | 4 +- .../src/ngx_http_lua_ssl_certby.c | 4 +- .../src/ngx_http_lua_ssl_client_helloby.c | 12 +++-- .../src/ngx_http_lua_ssl_session_fetchby.c | 4 +- .../lua-nginx-module/src/ngx_http_lua_timer.c | 4 +- src/deps/src/lua-nginx-module/t/014-bugs.t | 49 +++++++++++++++++++ .../lua-nginx-module/t/166-ssl-client-hello.t | 30 ++++++------ src/deps/src/lua-resty-core/.travis.yml | 2 +- .../lua-resty-core/lib/resty/core/base.lua | 9 ++-- .../lua-resty-core/lib/resty/core/time.lua | 9 ++-- .../lua-resty-core/lib/resty/core/worker.lua | 44 ++++++++++------- src/deps/src/lua-resty-core/t/count.t | 2 +- src/deps/src/lua-resty-core/t/ctx.t | 18 ++++--- .../src/lua-resty-core/t/ssl-session-fetch.t | 22 ++++++--- 24 files changed, 171 insertions(+), 92 deletions(-) diff --git a/src/deps/clone.sh b/src/deps/clone.sh index fbba4d337..38f985ddd 100755 --- a/src/deps/clone.sh +++ b/src/deps/clone.sh @@ -7,7 +7,7 @@ function git_update_checker() { mkdir -p "${main_tmp_folder}" echo "ℹ️ Check updates for ${repo}" folder="$(echo "$repo" | sed -E "s@https://github.com/.*/(.*)\.git@\1@")" - output="$(git clone "$repo" "${main_tmp_folder}/${folder}" 2>&1)" + output="$(git clone --recursive "$repo" "${main_tmp_folder}/${folder}")" if [ $? -ne 0 ] ; then echo "❌ Error cloning $1" echo "$output" @@ -64,7 +64,7 @@ function git_secure_clone() { commit="$2" folder="$(echo "$repo" | sed -E "s@https://github.com/.*/(.*)\.git@\1@")" if [ ! -d "deps/src/${folder}" ] ; then - output="$(git clone "$repo" "deps/src/${folder}" 2>&1)" + output="$(git clone --recursive "$repo" "deps/src/${folder}")" if [ $? -ne 0 ] ; then echo "❌ Error cloning $1" echo "$output" @@ -152,13 +152,13 @@ fi echo "ℹ️ Downloading LuaJIT" git_secure_clone "https://github.com/openresty/luajit2.git" "04f33ff01da97905a1641985fb5c840d234f97f1" -# lua-nginx-module v0.10.24 +# lua-nginx-module v0.10.25 echo "ℹ️ Downloading lua-nginx-module" -git_secure_clone "https://github.com/openresty/lua-nginx-module.git" "68acad14e4a8f42e31d4a4bb5ed44d6f5b55fc1c" +git_secure_clone "https://github.com/openresty/lua-nginx-module.git" "c47084b5d719ce507d2419d8660f39544a9d1fea" -# lua-resty-core v0.1.26 +# lua-resty-core v0.1.27 echo "ℹ️ Downloading lua-resty-core" -git_secure_clone "https://github.com/openresty/lua-resty-core.git" "407000a9856d3a5aab34e8c73f6ab0f049f8b8d7" +git_secure_clone "https://github.com/openresty/lua-resty-core.git" "31fae862a1ed64033591f991fadb0dd80358ba0b" # lua-resty-lrucache v0.13 echo "ℹ️ Downloading lua-resty-lrucache" @@ -349,4 +349,4 @@ git_secure_clone "https://github.com/vision5/ngx_devel_kit.git" "b4642d6ca01011b # stream-lua-nginx-module v0.0.13 echo "ℹ️ Downloading stream-lua-nginx-module" -git_secure_clone "https://github.com/openresty/stream-lua-nginx-module.git" "309198abf26266f1a3e53c71388ed7bb9d1e5ea2" \ No newline at end of file +git_secure_clone "https://github.com/openresty/stream-lua-nginx-module.git" "309198abf26266f1a3e53c71388ed7bb9d1e5ea2" diff --git a/src/deps/src/lua-nginx-module/src/api/ngx_http_lua_api.h b/src/deps/src/lua-nginx-module/src/api/ngx_http_lua_api.h index 018184990..640e0c396 100644 --- a/src/deps/src/lua-nginx-module/src/api/ngx_http_lua_api.h +++ b/src/deps/src/lua-nginx-module/src/api/ngx_http_lua_api.h @@ -19,7 +19,7 @@ /* Public API for other Nginx modules */ -#define ngx_http_lua_version 10024 +#define ngx_http_lua_version 10025 typedef struct ngx_http_lua_co_ctx_s ngx_http_lua_co_ctx_t; diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_accessby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_accessby.c index 58c251443..d40eab123 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_accessby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_accessby.c @@ -240,7 +240,7 @@ ngx_http_lua_access_by_chunk(lua_State *L, ngx_http_request_t *r) ngx_event_t *rev; ngx_connection_t *c; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_http_lua_loc_conf_t *llcf; @@ -291,9 +291,9 @@ ngx_http_lua_access_by_chunk(lua_State *L, ngx_http_request_t *r) /* }}} */ - /* {{{ register request cleanup hooks */ + /* {{{ register nginx pool cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_bodyfilterby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_bodyfilterby.c index a8a382ac4..78e3b5c2d 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_bodyfilterby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_bodyfilterby.c @@ -234,7 +234,7 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ngx_http_lua_ctx_t *ctx; ngx_int_t rc; uint16_t old_context; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_chain_t *out; ngx_chain_t *cl, *ln; ngx_http_lua_main_conf_t *lmcf; @@ -314,7 +314,7 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_common.h b/src/deps/src/lua-nginx-module/src/ngx_http_lua_common.h index d977ee8e3..843504549 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_common.h +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_common.h @@ -587,7 +587,7 @@ typedef struct ngx_http_lua_ctx_s { ngx_chain_t *filter_in_bufs; /* for the body filter */ ngx_chain_t *filter_busy_bufs; /* for the body filter */ - ngx_http_cleanup_pt *cleanup; + ngx_pool_cleanup_pt *cleanup; ngx_http_cleanup_t *free_cleanup; /* free list of cleanup records */ diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_contentby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_contentby.c index 76e6a074d..5e2ae5520 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_contentby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_contentby.c @@ -29,7 +29,7 @@ ngx_http_lua_content_by_chunk(lua_State *L, ngx_http_request_t *r) lua_State *co; ngx_event_t *rev; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_http_lua_loc_conf_t *llcf; @@ -83,7 +83,7 @@ ngx_http_lua_content_by_chunk(lua_State *L, ngx_http_request_t *r) /* {{{ register request cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_directive.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_directive.c index f1623056b..f42aae9d5 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_directive.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_directive.c @@ -1436,7 +1436,7 @@ ngx_http_lua_set_by_lua_init(ngx_http_request_t *r) { lua_State *L; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); if (ctx == NULL) { @@ -1451,7 +1451,7 @@ ngx_http_lua_set_by_lua_init(ngx_http_request_t *r) } if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_headerfilterby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_headerfilterby.c index f2fe165bd..71553558b 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_headerfilterby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_headerfilterby.c @@ -231,7 +231,7 @@ ngx_http_lua_header_filter(ngx_http_request_t *r) ngx_http_lua_loc_conf_t *llcf; ngx_http_lua_ctx_t *ctx; ngx_int_t rc; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; uint16_t old_context; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, @@ -260,7 +260,7 @@ ngx_http_lua_header_filter(ngx_http_request_t *r) } if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_rewriteby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_rewriteby.c index d1eabeccd..4109f288e 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_rewriteby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_rewriteby.c @@ -241,7 +241,7 @@ ngx_http_lua_rewrite_by_chunk(lua_State *L, ngx_http_request_t *r) ngx_event_t *rev; ngx_connection_t *c; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_http_lua_loc_conf_t *llcf; @@ -291,9 +291,9 @@ ngx_http_lua_rewrite_by_chunk(lua_State *L, ngx_http_request_t *r) /* }}} */ - /* {{{ register request cleanup hooks */ + /* {{{ register nginx pool cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_server_rewriteby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_server_rewriteby.c index 22bb69e8c..be860693f 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_server_rewriteby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_server_rewriteby.c @@ -199,7 +199,7 @@ ngx_http_lua_server_rewrite_by_chunk(lua_State *L, ngx_http_request_t *r) ngx_event_t *rev; ngx_connection_t *c; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_http_lua_loc_conf_t *llcf; @@ -251,7 +251,7 @@ ngx_http_lua_server_rewrite_by_chunk(lua_State *L, ngx_http_request_t *r) /* {{{ register request cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_socket_udp.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_socket_udp.c index cbb6621b4..10285f6d0 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_socket_udp.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_socket_udp.c @@ -591,7 +591,7 @@ ngx_http_lua_socket_resolve_retval_handler(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx; ngx_http_lua_co_ctx_t *coctx; ngx_connection_t *c; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_http_upstream_resolved_t *ur; ngx_int_t rc; ngx_http_lua_udp_connection_t *uc; @@ -625,7 +625,7 @@ ngx_http_lua_socket_resolve_retval_handler(ngx_http_request_t *r, } if (u->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { u->ft_type |= NGX_HTTP_LUA_SOCKET_FT_ERROR; lua_pushnil(L); diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_certby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_certby.c index 0499bfb35..b8e70ddef 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_certby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_certby.c @@ -453,7 +453,7 @@ ngx_http_lua_ssl_cert_by_chunk(lua_State *L, ngx_http_request_t *r) ngx_int_t rc; lua_State *co; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); @@ -507,7 +507,7 @@ ngx_http_lua_ssl_cert_by_chunk(lua_State *L, ngx_http_request_t *r) /* register request cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { rc = NGX_ERROR; ngx_http_lua_finalize_request(r, rc); diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_client_helloby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_client_helloby.c index 10500d89e..a1dac6188 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_client_helloby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_client_helloby.c @@ -150,14 +150,16 @@ ngx_http_lua_ssl_client_hello_by_lua(ngx_conf_t *cf, ngx_command_t *cmd, lscf->srv.ssl_client_hello_src.len = ngx_strlen(name); } else { - cache_key = ngx_http_lua_gen_file_cache_key(cf, value[1].data, - value[1].len); + cache_key = ngx_http_lua_gen_chunk_cache_key(cf, + "ssl_client_hello_by_lua", + value[1].data, + value[1].len); if (cache_key == NULL) { return NGX_CONF_ERROR; } chunkname = ngx_http_lua_gen_chunk_name(cf, "ssl_client_hello_by_lua", - sizeof("ssl_client_helloo_by_lua")- 1, + sizeof("ssl_client_hello_by_lua")- 1, &chunkname_len); if (chunkname == NULL) { return NGX_CONF_ERROR; @@ -447,7 +449,7 @@ ngx_http_lua_ssl_client_hello_by_chunk(lua_State *L, ngx_http_request_t *r) ngx_int_t rc; lua_State *co; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); @@ -501,7 +503,7 @@ ngx_http_lua_ssl_client_hello_by_chunk(lua_State *L, ngx_http_request_t *r) /* register request cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { rc = NGX_ERROR; ngx_http_lua_finalize_request(r, rc); diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_session_fetchby.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_session_fetchby.c index 66e984855..ebce63ce2 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_session_fetchby.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_ssl_session_fetchby.c @@ -477,7 +477,7 @@ ngx_http_lua_ssl_sess_fetch_by_chunk(lua_State *L, ngx_http_request_t *r) ngx_int_t rc; lua_State *co; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); @@ -531,7 +531,7 @@ ngx_http_lua_ssl_sess_fetch_by_chunk(lua_State *L, ngx_http_request_t *r) /* register request cleanup hooks */ if (ctx->cleanup == NULL) { - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { rc = NGX_ERROR; ngx_http_lua_finalize_request(r, rc); diff --git a/src/deps/src/lua-nginx-module/src/ngx_http_lua_timer.c b/src/deps/src/lua-nginx-module/src/ngx_http_lua_timer.c index 060cab543..11d29349a 100644 --- a/src/deps/src/lua-nginx-module/src/ngx_http_lua_timer.c +++ b/src/deps/src/lua-nginx-module/src/ngx_http_lua_timer.c @@ -519,7 +519,7 @@ ngx_http_lua_timer_handler(ngx_event_t *ev) ngx_connection_t *c = NULL; ngx_http_request_t *r = NULL; ngx_http_lua_ctx_t *ctx; - ngx_http_cleanup_t *cln; + ngx_pool_cleanup_t *cln; ngx_pool_cleanup_t *pcln; ngx_http_lua_timer_ctx_t tctx; @@ -620,7 +620,7 @@ ngx_http_lua_timer_handler(ngx_event_t *ev) L = ngx_http_lua_get_lua_vm(r, ctx); - cln = ngx_http_cleanup_add(r, 0); + cln = ngx_pool_cleanup_add(r->pool, 0); if (cln == NULL) { errmsg = "could not add request cleanup"; goto failed; diff --git a/src/deps/src/lua-nginx-module/t/014-bugs.t b/src/deps/src/lua-nginx-module/t/014-bugs.t index bfc86c9e9..877aecfdb 100644 --- a/src/deps/src/lua-nginx-module/t/014-bugs.t +++ b/src/deps/src/lua-nginx-module/t/014-bugs.t @@ -1283,3 +1283,52 @@ Hello world --- shutdown_error_log eval qr|failed to read a line: closed| --- timeout: 1.2 + + + +=== TEST 48: nginx crashes when encountering an illegal http if header +crash with ngx.send_headers() +--- main_config +--- config +error_page 412 /my_error_handler_412; + +location /t { + rewrite_by_lua_block { + ngx.send_headers() + -- ngx.print() -- this also triggers the bug + } +} +location = /my_error_handler_412 { + return 412 "hello"; +} +--- request + GET /t +--- more_headers +If-Match: 1 +--- error_code: 412 +--- response_body eval +qr/\Ahello\z/ + + + +=== TEST 49: nginx crashes when encountering an illegal http if header +crash with ngx.print() +--- main_config +--- config +error_page 412 /my_error_handler_412; + +location /t { + rewrite_by_lua_block { + ngx.print() + } +} +location = /my_error_handler_412 { + return 412 "hello"; +} +--- request + GET /t +--- more_headers +If-Match: 1 +--- error_code: 412 +--- response_body eval +qr/\Ahello\z/ diff --git a/src/deps/src/lua-nginx-module/t/166-ssl-client-hello.t b/src/deps/src/lua-nginx-module/t/166-ssl-client-hello.t index da021300a..850a0d655 100644 --- a/src/deps/src/lua-nginx-module/t/166-ssl-client-hello.t +++ b/src/deps/src/lua-nginx-module/t/166-ssl-client-hello.t @@ -117,18 +117,18 @@ lua ssl server name: "test.com" --- no_error_log [error] [alert] ---- grep_error_log eval: qr/ssl_client_hello_by_lua:.*?,|\bssl client hello: connection reusable: \d+|\breusable connection: \d+/ +--- grep_error_log eval: qr/ssl_client_hello_by_lua\(.*?,|\bssl client hello: connection reusable: \d+|\breusable connection: \d+/ --- grep_error_log_out eval # Since nginx version 1.17.9, nginx call ngx_reusable_connection(c, 0) # before call ssl callback function $Test::Nginx::Util::NginxVersion >= 1.017009 ? qr/reusable connection: 0 ssl client hello: connection reusable: 0 -ssl_client_hello_by_lua:1: ssl client hello by lua is running!,/ +ssl_client_hello_by_lua\(nginx.conf:\d+\):1: ssl client hello by lua is running!,/ : qr /reusable connection: 1 ssl client hello: connection reusable: 1 reusable connection: 0 -ssl_client_hello_by_lua:1: ssl client hello by lua is running!,/ +ssl_client_hello_by_lua\(nginx.conf:\d+\):1: ssl client hello by lua is running!,/ @@ -789,7 +789,7 @@ failed to do SSL handshake: handshake failed --- error_log eval [ -'runtime error: ssl_client_hello_by_lua:2: bad bad bad', +'runtime error: ssl_client_hello_by_lua(nginx.conf:28):2: bad bad bad', 'lua_client_hello_by_lua: handler return value: 500, client hello cb exit code: 0', qr/\[info\] .*? SSL_do_handshake\(\) failed .*?callback failed/, qr/context: ssl_client_hello_by_lua\*, client: \d+\.\d+\.\d+\.\d+, server: \d+\.\d+\.\d+\.\d+:\d+/, @@ -861,7 +861,7 @@ failed to do SSL handshake: handshake failed --- error_log eval [ -'runtime error: ssl_client_hello_by_lua:3: bad bad bad', +'runtime error: ssl_client_hello_by_lua(nginx.conf:28):3: bad bad bad', 'lua_client_hello_by_lua: client hello cb exit code: 0', qr/\[info\] .*? SSL_do_handshake\(\) failed .*?callback failed/, ] @@ -1048,7 +1048,7 @@ failed to do SSL handshake: handshake failed --- error_log eval [ 'lua ssl server name: "test.com"', -'ssl_client_hello_by_lua:1: API disabled in the context of ssl_client_hello_by_lua*', +'ssl_client_hello_by_lua(nginx.conf:28):1: API disabled in the context of ssl_client_hello_by_lua*', qr/\[info\] .*?callback failed/, ] @@ -1479,7 +1479,7 @@ close: 1 nil --- error_log lua ssl server name: "test.com" -ssl_client_hello_by_lua:1: ssl client hello by lua is running! +ssl_client_hello_by_lua(nginx.conf:25):1: ssl client hello by lua is running! --- no_error_log [error] @@ -1574,7 +1574,7 @@ close: 1 nil --- error_log lua ssl server name: "test.com" -ssl_client_hello_by_lua:1: ssl client hello by lua on the server level is running! +ssl_client_hello_by_lua(nginx.conf:31):1: ssl client hello by lua on the server level is running! --- no_error_log [error] @@ -1657,7 +1657,7 @@ received: foo close: 1 nil --- no_error_log -ssl_client_hello_by_lua:1: ssl client hello by lua is running! +ssl client hello by lua is running! [error] [alert] @@ -1738,7 +1738,7 @@ received: foo close: 1 nil --- no_error_log -ssl_client_hello_by_lua:1: ssl client hello by lua is running! +ssl client hello by lua is running! [error] [alert] @@ -1830,7 +1830,7 @@ close: 1 nil --- error_log lua ssl server name: "test.com" -ssl_client_hello_by_lua:1: ssl client hello by lua is running! +ssl_client_hello_by_lua(nginx.conf:28):1: ssl client hello by lua is running! --- no_error_log [error] @@ -1915,7 +1915,7 @@ close: 1 nil --- no_error_log -ssl_client_hello_by_lua:1: ssl client hello by lua is running! +ssl client hello by lua is running! [error] [alert] @@ -2018,10 +2018,10 @@ close: 1 nil --- error_log lua ssl server name: "test.com" -ssl_client_hello_by_lua:1: ssl client hello by lua in server1 is running! +ssl_client_hello_by_lua(nginx.conf:29):1: ssl client hello by lua in server1 is running! --- no_error_log -ssl_client_hello_by_lua:1: ssl client hello by lua in server2 is running! +ssl client hello by lua in server2 is running! [error] [alert] @@ -2121,7 +2121,7 @@ qr/\[error\] .*? send\(\) failed/, ] --- no_error_log [alert] -ssl_client_hello_by_lua:1: ssl client hello by lua is running! +ssl client hello by lua is running! diff --git a/src/deps/src/lua-resty-core/.travis.yml b/src/deps/src/lua-resty-core/.travis.yml index 6223540cb..2223d31ba 100644 --- a/src/deps/src/lua-resty-core/.travis.yml +++ b/src/deps/src/lua-resty-core/.travis.yml @@ -45,7 +45,7 @@ env: - TEST_NGINX_RANDOMIZE=1 - LUACHECK_VER=0.21.1 matrix: - - NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.1s OPENSSL_PATCH_VER=1.1.1f + - NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.1u OPENSSL_PATCH_VER=1.1.1f services: - memcache diff --git a/src/deps/src/lua-resty-core/lib/resty/core/base.lua b/src/deps/src/lua-resty-core/lib/resty/core/base.lua index f9269ca7d..540a4586a 100644 --- a/src/deps/src/lua-resty-core/lib/resty/core/base.lua +++ b/src/deps/src/lua-resty-core/lib/resty/core/base.lua @@ -19,9 +19,9 @@ local FREE_LIST_REF = 0 if subsystem == 'http' then if not ngx.config or not ngx.config.ngx_lua_version - or ngx.config.ngx_lua_version ~= 10024 + or ngx.config.ngx_lua_version ~= 10025 then - error("ngx_http_lua_module 0.10.24 required") + error("ngx_http_lua_module 0.10.25 required") end elseif subsystem == 'stream' then @@ -33,7 +33,7 @@ elseif subsystem == 'stream' then end else - error("ngx_http_lua_module 0.10.24 or " + error("ngx_http_lua_module 0.10.25 or " .. "ngx_stream_lua_module 0.0.13 required") end @@ -141,7 +141,7 @@ local c_buf_type = ffi.typeof("char[?]") local _M = new_tab(0, 18) -_M.version = "0.1.26" +_M.version = "0.1.27" _M.new_tab = new_tab _M.clear_tab = clear_tab @@ -241,6 +241,7 @@ _M.FFI_AGAIN = -2 _M.FFI_BUSY = -3 _M.FFI_DONE = -4 _M.FFI_DECLINED = -5 +_M.FFI_ABORT = -6 do diff --git a/src/deps/src/lua-resty-core/lib/resty/core/time.lua b/src/deps/src/lua-resty-core/lib/resty/core/time.lua index cf8f72eb3..140cb4e21 100644 --- a/src/deps/src/lua-resty-core/lib/resty/core/time.lua +++ b/src/deps/src/lua-resty-core/lib/resty/core/time.lua @@ -72,12 +72,14 @@ end function ngx.now() - return tonumber(ngx_lua_ffi_now()) + local now = tonumber(ngx_lua_ffi_now()) + return now end function ngx.time() - return tonumber(ngx_lua_ffi_time()) + local time = tonumber(ngx_lua_ffi_time()) + return time end @@ -168,7 +170,8 @@ function ngx.parse_http_time(time_str) return nil end - return tonumber(res) + local time = tonumber(res) + return time end end diff --git a/src/deps/src/lua-resty-core/lib/resty/core/worker.lua b/src/deps/src/lua-resty-core/lib/resty/core/worker.lua index d62e851c3..934070d8b 100644 --- a/src/deps/src/lua-resty-core/lib/resty/core/worker.lua +++ b/src/deps/src/lua-resty-core/lib/resty/core/worker.lua @@ -23,7 +23,14 @@ local ffi_intp_type = ffi.typeof("int *") local ffi_int_size = ffi.sizeof("int") -ngx.worker = new_tab(0, 4) +local is_not_windows = jit.os ~= "Windows" + +if is_not_windows then + ngx.worker = new_tab(0, 5) + +else + ngx.worker = new_tab(0, 4) +end if subsystem == "http" then @@ -38,13 +45,6 @@ if subsystem == "http" then ngx_lua_ffi_worker_pid = C.ngx_http_lua_ffi_worker_pid ngx_lua_ffi_worker_count = C.ngx_http_lua_ffi_worker_count ngx_lua_ffi_worker_exiting = C.ngx_http_lua_ffi_worker_exiting - if jit.os ~= "Windows" then - ffi.cdef[[ - int ngx_http_lua_ffi_worker_pids(int *pids, size_t *pids_len); - ]] - - ngx_lua_ffi_worker_pids = C.ngx_http_lua_ffi_worker_pids - end elseif subsystem == "stream" then ffi.cdef[[ @@ -59,13 +59,6 @@ elseif subsystem == "stream" then ngx_lua_ffi_worker_count = C.ngx_stream_lua_ffi_worker_count ngx_lua_ffi_worker_exiting = C.ngx_stream_lua_ffi_worker_exiting - if jit.os ~= "Windows" then - ffi.cdef[[ - int ngx_stream_lua_ffi_worker_pids(int *pids, size_t *pids_len); - ]] - - ngx_lua_ffi_worker_pids = C.ngx_stream_lua_ffi_worker_pids - end end @@ -79,7 +72,23 @@ function ngx.worker.pid() end -if jit.os ~= "Windows" then +if is_not_windows then + if subsystem == "http" then + ffi.cdef[[ + int ngx_http_lua_ffi_worker_pids(int *pids, size_t *pids_len); + ]] + + ngx_lua_ffi_worker_pids = C.ngx_http_lua_ffi_worker_pids + + elseif subsystem == "stream" then + ffi.cdef[[ + int ngx_stream_lua_ffi_worker_pids(int *pids, size_t *pids_len); + ]] + + ngx_lua_ffi_worker_pids = C.ngx_stream_lua_ffi_worker_pids + end + + function ngx.worker.pids() if ngx.get_phase() == "init" or ngx.get_phase() == "init_worker" then return nil, "API disabled in the current context" @@ -100,9 +109,10 @@ if jit.os ~= "Windows" then if res == 0 then for i = 1, tonumber(size_ptr[0]) do - pids[i] = intp_buf[i-1] + pids[i] = intp_buf[i - 1] end end + return pids end end diff --git a/src/deps/src/lua-resty-core/t/count.t b/src/deps/src/lua-resty-core/t/count.t index 416a42a0f..9d7cc6c95 100644 --- a/src/deps/src/lua-resty-core/t/count.t +++ b/src/deps/src/lua-resty-core/t/count.t @@ -40,6 +40,6 @@ probe process("$LIBLUA_PATH").function("rehashtab") { } --- response_body -base size: 19 +base size: 20 --- no_error_log [error] diff --git a/src/deps/src/lua-resty-core/t/ctx.t b/src/deps/src/lua-resty-core/t/ctx.t index 893efc471..9a00a8265 100644 --- a/src/deps/src/lua-resty-core/t/ctx.t +++ b/src/deps/src/lua-resty-core/t/ctx.t @@ -608,8 +608,10 @@ GET /t --- grep_error_log eval qr/(received: \w+|lua release ngx.ctx at ref \d+)/ --- grep_error_log_out eval -["", -"lua release ngx.ctx at ref 2 +["lua release ngx.ctx at ref 1 +", +"lua release ngx.ctx at ref 1 +lua release ngx.ctx at ref 2 received: 42 received: 1 lua release ngx.ctx at ref 2 @@ -674,8 +676,10 @@ closed --- grep_error_log eval qr/lua release ngx.ctx at ref \d+/ --- grep_error_log_out eval -["", +["lua release ngx.ctx at ref 1 +", "lua release ngx.ctx at ref 1 +lua release ngx.ctx at ref 1 "] --- no_error_log [error] @@ -772,15 +776,15 @@ GET /t qr/(received: \w+|lua release ngx.ctx at ref \d+)/ --- grep_error_log_out eval ["lua release ngx.ctx at ref 2 -received: 102 +received: 112 lua release ngx.ctx at ref 2 -received: 102 +received: 112 lua release ngx.ctx at ref 1 ", "lua release ngx.ctx at ref 2 -received: 102 +received: 112 lua release ngx.ctx at ref 2 -received: 102 +received: 112 lua release ngx.ctx at ref 1 lua release ngx.ctx at ref 2 received: 112 diff --git a/src/deps/src/lua-resty-core/t/ssl-session-fetch.t b/src/deps/src/lua-resty-core/t/ssl-session-fetch.t index 879f464d9..48878602b 100644 --- a/src/deps/src/lua-resty-core/t/ssl-session-fetch.t +++ b/src/deps/src/lua-resty-core/t/ssl-session-fetch.t @@ -97,7 +97,7 @@ qr/ssl_session_fetch_by_lua\(nginx.conf:\d+\):\d+: session id: [a-fA-f\d]+/s --- grep_error_log_out eval [ -'', +qr/ssl_session_fetch_by_lua\(nginx.conf:\d+\):4: session id: [a-fA-f\d]+/s, qr/ssl_session_fetch_by_lua\(nginx.conf:\d+\):4: session id: [a-fA-f\d]+/s, qr/ssl_session_fetch_by_lua\(nginx.conf:\d+\):4: session id: [a-fA-f\d]+/s, ] @@ -184,7 +184,8 @@ qr/ssl_session_fetch_by_lua:\d: session size: [a-fA-f\d]+|get session error: bad --- grep_error_log_out eval [ -'', +'get session error: bad session in lua context +', 'get session error: bad session in lua context ', 'get session error: bad session in lua context @@ -220,7 +221,11 @@ In practice, never store session in plaintext on persistent storage. local ssl = require "ngx.ssl.session" local sid = ssl.get_session_id() print("session id: ", sid) - local f = assert(io.open("$TEST_NGINX_SERVER_ROOT/html/session.tmp")) + local f = io.open("$TEST_NGINX_SERVER_ROOT/html/session.tmp") + if f == nil then + return + end + local sess = f:read("*a") f:close() ssl.set_serialized_session(sess) @@ -383,7 +388,10 @@ qr/failed to resume session: failed to de-serialize session|ssl_session_(fetch|s --- grep_error_log_out eval [ -qr/^ssl_session_store_by_lua\(nginx.conf:\d+\):5: session id: [a-fA-F\d]+$/s, +qr/^ssl_session_fetch_by_lua\(nginx.conf:\d+\):4: session id: [a-fA-F\d]+ +failed to resume session: failed to de-serialize session +ssl_session_store_by_lua\(nginx.conf:\d+\):5: session id: [a-fA-F\d]+ +$/s, qr/^ssl_session_fetch_by_lua\(nginx.conf:\d+\):4: session id: [a-fA-F\d]+ failed to resume session: failed to de-serialize session ssl_session_store_by_lua\(nginx.conf:\d+\):5: session id: [a-fA-F\d]+ @@ -393,7 +401,6 @@ failed to resume session: failed to de-serialize session ssl_session_store_by_lua\(nginx.conf:\d+\):5: session id: [a-fA-F\d]+ $/s, ] - --- no_error_log [alert] [emerg] @@ -527,7 +534,10 @@ $/s, ssl_session_fetch_by_lua_block { local ssl = require "ngx.ssl.session" - local f = assert(io.open("$TEST_NGINX_SERVER_ROOT/html/session.tmp")) + local f = io.open("$TEST_NGINX_SERVER_ROOT/html/session.tmp") + if f == nil then + return + end local sess = f:read("*a") f:close() ssl.set_serialized_session(sess)