mirror of
https://github.com/darlinghq/darlingserver.git
synced 2024-11-23 04:19:44 +00:00
[rpc] Don't set the control buffer if we have no FDs to send
If `valid_fd_count` is 0, we can simply not set a control buffer. This is necessary because empty control buffers with no content are invalid. It seems that, due to some coincidence with struct sizes, this went undetected on x86_64. However, the issue is present on i386.
This commit is contained in:
parent
dac0e1333f
commit
0a58b40d68
@ -1331,18 +1331,20 @@ for call in calls:
|
||||
library_source.write("\t\t.msg_control = NULL,\n")
|
||||
library_source.write("\t\t.msg_controllen = 0,\n")
|
||||
else:
|
||||
library_source.write("\t\t.msg_control = controlbuf,\n")
|
||||
library_source.write("\t\t.msg_controllen = sizeof(controlbuf),\n")
|
||||
library_source.write("\t\t.msg_control = (valid_fd_count > 0) ? controlbuf : NULL,\n")
|
||||
library_source.write("\t\t.msg_controllen = (valid_fd_count > 0) ? sizeof(controlbuf) : 0,\n")
|
||||
|
||||
library_source.write("\t};\n")
|
||||
|
||||
if fd_count_in_call > 0:
|
||||
library_source.write(textwrap.indent(textwrap.dedent("""\
|
||||
dserver_rpc_hooks_cmsghdr_t* call_cmsg = DSERVER_RPC_HOOKS_CMSG_FIRSTHDR(&callmsg);
|
||||
call_cmsg->cmsg_level = DSERVER_RPC_HOOKS_SOL_SOCKET;
|
||||
call_cmsg->cmsg_type = DSERVER_RPC_HOOKS_SCM_RIGHTS;
|
||||
call_cmsg->cmsg_len = DSERVER_RPC_HOOKS_CMSG_LEN(sizeof(int) * valid_fd_count);
|
||||
dserver_rpc_hooks_memcpy(DSERVER_RPC_HOOKS_CMSG_DATA(call_cmsg), fds, sizeof(int) * valid_fd_count);
|
||||
if (valid_fd_count > 0) {
|
||||
dserver_rpc_hooks_cmsghdr_t* call_cmsg = DSERVER_RPC_HOOKS_CMSG_FIRSTHDR(&callmsg);
|
||||
call_cmsg->cmsg_level = DSERVER_RPC_HOOKS_SOL_SOCKET;
|
||||
call_cmsg->cmsg_type = DSERVER_RPC_HOOKS_SCM_RIGHTS;
|
||||
call_cmsg->cmsg_len = DSERVER_RPC_HOOKS_CMSG_LEN(sizeof(int) * valid_fd_count);
|
||||
dserver_rpc_hooks_memcpy(DSERVER_RPC_HOOKS_CMSG_DATA(call_cmsg), fds, sizeof(int) * valid_fd_count);
|
||||
}
|
||||
"""), '\t'))
|
||||
|
||||
library_source.write(textwrap.indent(textwrap.dedent("""\
|
||||
|
Loading…
Reference in New Issue
Block a user