diff options
| author | Andrew Clayton <a.clayton@nginx.com> | 2025-04-09 17:00:38 +0100 |
|---|---|---|
| committer | Andrew Clayton <a.clayton@nginx.com> | 2025-04-11 17:56:17 +0100 |
| commit | 89149c066cd5e929a6ca7a538a81480536aea61d (patch) | |
| tree | 0fb08c12b3caa90df2212610d7d0eb6fc6f42e19 | |
| parent | 326f42a5f85d4154810a16e5554769ade5abd54a (diff) | |
| download | unit-89149c066cd5e929a6ca7a538a81480536aea61d.tar.gz unit-89149c066cd5e929a6ca7a538a81480536aea61d.tar.bz2 | |
Fully initialise the oob struct in nxt_socket_msg_oob_init()
valgrind(1) was producing the following alert
==166470== Syscall param sendmsg(msg.msg_control) points to uninitialised byte(s)
==166470== at 0x4AE6514: sendmsg (sendmsg.c:28)
==166470== by 0x42D86C: nxt_sendmsg (nxt_socket_msg.c:32)
==166470== by 0x4FE6695: nxt_unit_sendmsg (nxt_unit.c:6013)
==166470== by 0x4FEB6E2: nxt_unit_ready (nxt_unit.c:963)
==166470== by 0x4FEB6E2: nxt_unit_init (nxt_unit.c:557)
==166470== by 0x4FEEC56: nxt_php_start (nxt_php_sapi.c:507)
==166470== by 0x426BA0: nxt_app_setup (nxt_application.c:1029)
==166470== by 0x403153: nxt_process_do_start (nxt_process.c:718)
==166470== by 0x4042A3: nxt_process_whoami_ok (nxt_process.c:846)
==166470== by 0x407A28: nxt_port_rpc_handler (nxt_port_rpc.c:347)
==166470== by 0x407E42: nxt_port_handler (nxt_port.c:184)
==166470== by 0x40501B: nxt_port_read_msg_process (nxt_port_socket.c:1271)
==166470== by 0x4055B3: nxt_port_read_handler (nxt_port_socket.c:778)
==166470== Address 0x1ffefffc9c is on thread 1's stack
==166470== in frame #3, created by nxt_unit_init (nxt_unit.c:428)
==166470== Uninitialised value was created by a stack allocation
==166470== at 0x4FEABFE: nxt_unit_init (nxt_unit.c:436)
This was due to the nxt_send_oob_t oob structure not being fully
initialised.
Given the name and intention of this function lets *fully*
empty-initialise this structure.
Link: <https://en.cppreference.com/w/c/language/initialization#Empty_initialization>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
| -rw-r--r-- | src/nxt_socket_msg.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nxt_socket_msg.h b/src/nxt_socket_msg.h index 81617bd6..8a36245c 100644 --- a/src/nxt_socket_msg.h +++ b/src/nxt_socket_msg.h @@ -89,6 +89,8 @@ nxt_socket_msg_oob_init(nxt_send_oob_t *oob, int *fds) int nfds; struct cmsghdr *cmsg; + *oob = (nxt_send_oob_t) {}; + #if (NXT_HAVE_MSGHDR_CMSGCRED) cmsg = (struct cmsghdr *) (oob->buf); /* |
