Skip to content

Commit 74a7a83

Browse files
author
jiahao
committed
bugfix: append new parameters to ngx_lua_ffi_ssl_verify_client at function end.
Avoid inserting new parameters in the middle of the function to prevent core dumps when using old lua-resty-core with new lua-nginx-module. Example stack trace: ``` Message: Process 2199905 (nginx) of user 1000 dumped core. Stack trace of thread 2199905: #0 0x00007ffaf1e4b385 in OPENSSL_sk_num (st=st@entry=0xffffffff) at crypto/stack/stack.c:382 openresty#1 0x0000000000510aba in sk_X509_num (sk=0xffffffff) at /opt/ssl/include/openssl/x509.h:99 openresty#2 ngx_http_lua_ffi_ssl_verify_client (r=<optimized out>, client_certs=<optimized out>, trusted_certs=0xffffffff, depth=<optimized out>, err=0x0) at /home/jiahao/work/org/lua-nginx-module/src/ngx_http_lua_ssl_certby.c:1588 ```
1 parent 817a220 commit 74a7a83

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/ngx/ssl.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ if subsystem == 'http' then
100100
void ngx_http_lua_ffi_free_priv_key(void *cdata);
101101

102102
int ngx_http_lua_ffi_ssl_verify_client(void *r,
103-
void *client_certs, void *trusted_certs, int depth, char **err);
103+
void *client_certs, int depth, char **err, void *trusted_certs);
104104

105105
int ngx_http_lua_ffi_ssl_client_random(ngx_http_request_t *r,
106106
const unsigned char *out, size_t *outlen, char **err);
@@ -494,8 +494,8 @@ function _M.verify_client(client_certs, depth, trusted_certs)
494494
depth = -1
495495
end
496496

497-
local rc = ngx_lua_ffi_ssl_verify_client(r, client_certs, trusted_certs,
498-
depth, errmsg)
497+
local rc = ngx_lua_ffi_ssl_verify_client(r, client_certs, depth, errmsg,
498+
trusted_certs)
499499
if rc == FFI_OK then
500500
return true
501501
end

0 commit comments

Comments
 (0)