Skip to content

THRIFT-5933: c_glib: reject oversized Unix socket paths in thrift_socket_open()#3356

Open
neosys007 wants to merge 1 commit intoapache:masterfrom
neosys007:codex/thrift-5933-client-sun_path
Open

THRIFT-5933: c_glib: reject oversized Unix socket paths in thrift_socket_open()#3356
neosys007 wants to merge 1 commit intoapache:masterfrom
neosys007:codex/thrift-5933-client-sun_path

Conversation

@neosys007
Copy link
Copy Markdown
Contributor

This PR fixes the client-side Unix socket path copy in the C GLib transport.

In current head, thrift_socket_open() builds a stack sockaddr_un and copies tsocket->path into sun_path with strlen(path) + 1. That only works when the configured path is shorter than the destination buffer; otherwise the copy can run past the end of the local sockaddr_un before connect() is even called.

The fix mirrors the server-side transport:

  • check the configured path length before the copy,
  • return a transport error if the path is too long,
  • leave the AF_INET path unchanged.

I also added regression coverage in lib/c_glib/test/testtransportsocket.c that checks the client open path rejects an overlong Unix socket path cleanly.

Validation performed locally:

  • git diff --check
  • syntax-only compile for the changed C files
  • the C GLib transport sources compile cleanly apart from existing OpenSSL deprecation warnings unrelated to this change.

Related Jira:

…ket_open()

thrift_socket_open() still copies the configured Unix socket path directly into a stack sockaddr_un and then connects it. The path is stored via a GObject property and is not checked against sizeof(pin.sun_path) before the copy.

Reject Unix socket paths that do not fit in the local sockaddr_un.sun_path buffer before building the sockaddr and connecting the socket.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
@mergeable mergeable bot added the c_glib label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant