Skip to content

bugfix: stream cosocket getsslctx() bound to wrong FFI symbol#1

Open
perfgao wants to merge 1 commit into
masterfrom
fix/stream-getsslctx-wrong-binding
Open

bugfix: stream cosocket getsslctx() bound to wrong FFI symbol#1
perfgao wants to merge 1 commit into
masterfrom
fix/stream-getsslctx-wrong-binding

Conversation

@perfgao

@perfgao perfgao commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

In lib/resty/core/socket.lua, the stream branch binds ngx_lua_ffi_socket_getsslctx to ngx_stream_lua_ffi_socket_tcp_get_ssl_pointer — a copy/paste from the getsslpointer block above. Compare http branch at lines 103-104, which correctly uses _get_ssl_ctx.

Impact

stream cosocket:getsslctx() actually returns SSL * while callers treat it as SSL_CTX * → UB / potential segfault.

Fix

Bind to ngx_stream_lua_ffi_socket_tcp_get_ssl_ctx (declaration already in the stream ffi.cdef).

Upstream PR: openresty#530

The stream branch in lib/resty/core/socket.lua bound
ngx_lua_ffi_socket_getsslctx to ngx_stream_lua_ffi_socket_tcp_get_ssl_pointer
(a copy/paste of the getsslpointer block above). As a result,
stream cosocket:getsslctx() returned an SSL* while callers used it as
SSL_CTX*, leading to undefined behavior. Bind to
ngx_stream_lua_ffi_socket_tcp_get_ssl_ctx instead, matching the http branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant