From: claudio Date: Tue, 24 Oct 2023 14:05:23 +0000 (+0000) Subject: Require callers to use ibuf_fd_get() to extract the passed fd from an ibuf. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d8d5a064017c2464a25817d4f5f7e10f8c46d283;p=openbsd 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@ --- 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 @@ -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); }