Skip to content

Commit 459721f

Browse files
committed
Don't leak file descriptor in nxt_main_port_access_log_handler()
After opening a file and setting file.fd we _may_ call nxt_port_socket_write(). If so then the file is eventually closed via something like nxt_port_socket_write() nxt_port_socket_write2() nxt_port_write_handler() nxt_port_msg_close_fd() nxt_port_close_fds() Alternatively we may just return from the function and never close(2) file.fd. In which case we should call nxt_file_close(). This was reported by coverity. Signed-off-by: Andrew Clayton <[email protected]>
1 parent eb86f2b commit 459721f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/nxt_main_process.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,5 +1730,8 @@ nxt_main_port_access_log_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
17301730
if (nxt_fast_path(port != NULL)) {
17311731
(void) nxt_port_socket_write(task, port, type, file.fd,
17321732
msg->port_msg.stream, 0, NULL);
1733+
1734+
} else {
1735+
nxt_file_close(task, &file);
17331736
}
17341737
}

0 commit comments

Comments
 (0)