diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-10-24 14:05:24 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-10-24 14:05:24 +0000 |
commit | fc760de2fb35da3b65ffca4452c9048b4efd845a (patch) | |
tree | 6f6f1f9b73d97dbbac19f38ade05889502c53362 /lib/libutil | |
parent | a082db45088f4a56a9c5d61ceb0f40a408b06ec1 (diff) |
Require callers to use ibuf_fd_get() to extract the passed fd from an ibuf.
In imsg_free() close any fd that was not claimed automatically to prevent
filedescriptor leaks. In ibuf_dequeue() remvoe code which is now part of
imsg_free().
OK tb@
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/imsg-buffer.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/lib/libutil/imsg-buffer.c b/lib/libutil/imsg-buffer.c index 750d7c07702..e54904226eb 100644 --- a/lib/libutil/imsg-buffer.c +++ b/lib/libutil/imsg-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg-buffer.c,v 1.16 2023/06/19 17:19:50 claudio Exp $ */ +/* $OpenBSD: imsg-buffer.c,v 1.17 2023/10/24 14:05:23 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -294,10 +294,8 @@ ibuf_free(struct ibuf *buf) { if (buf == NULL) return; -#ifdef NOTYET if (buf->fd != -1) close(buf->fd); -#endif freezero(buf->buf, buf->size); free(buf); } @@ -314,9 +312,7 @@ ibuf_fd_get(struct ibuf *buf) int fd; fd = buf->fd; -#ifdef NOTYET buf->fd = -1; -#endif return (fd); } @@ -481,11 +477,6 @@ ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf) { TAILQ_REMOVE(&msgbuf->bufs, buf, entry); - if (buf->fd != -1) { - close(buf->fd); - buf->fd = -1; - } - msgbuf->queued--; ibuf_free(buf); } |