From 8a53274a29237e1edd7e34dcab81c7202c75d2cf Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 16 Jan 2024 13:09:11 +0000 Subject: [PATCH] Use imsg_get_fd() instead of direct access to imsg.fd The change in proc.c can be further simplified once imsg_free() takes care of unclaimed file descriptors. OK nicm@ --- usr.bin/tmux/proc.c | 7 ++++--- usr.bin/tmux/server-client.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/usr.bin/tmux/proc.c b/usr.bin/tmux/proc.c index b82a6058ec7..f0c7e547c96 100644 --- a/usr.bin/tmux/proc.c +++ b/usr.bin/tmux/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.22 2022/05/30 12:48:57 nicm Exp $ */ +/* $OpenBSD: proc.c,v 1.23 2024/01/16 13:09:11 claudio Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -92,8 +92,9 @@ proc_event_cb(__unused int fd, short events, void *arg) log_debug("peer %p message %d", peer, imsg.hdr.type); if (peer_check_version(peer, &imsg) != 0) { - if (imsg.fd != -1) - close(imsg.fd); + int fd = imsg_get_fd(&imsg); + if (fd != -1) + close(fd); imsg_free(&imsg); break; } diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index e94bd708fa1..01e3bd1ac6b 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.403 2023/12/27 20:23:59 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.404 2024/01/16 13:09:11 claudio Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -3002,14 +3002,14 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg) case MSG_IDENTIFY_STDIN: if (datalen != 0) fatalx("bad MSG_IDENTIFY_STDIN size"); - c->fd = imsg->fd; - log_debug("client %p IDENTIFY_STDIN %d", c, imsg->fd); + c->fd = imsg_get_fd(imsg); + log_debug("client %p IDENTIFY_STDIN %d", c, c->fd); break; case MSG_IDENTIFY_STDOUT: if (datalen != 0) fatalx("bad MSG_IDENTIFY_STDOUT size"); - c->out_fd = imsg->fd; - log_debug("client %p IDENTIFY_STDOUT %d", c, imsg->fd); + c->out_fd = imsg_get_fd(imsg); + log_debug("client %p IDENTIFY_STDOUT %d", c, c->out_fd); break; case MSG_IDENTIFY_ENVIRON: if (datalen == 0 || data[datalen - 1] != '\0') -- 2.20.1