Date: Thu, 11 Dec 2025 09:25:52 +0000 From: Kristof Provost <kp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: f629ee03fa78 - stable/15 - libpfctl: improve error handling Message-ID: <693a8e20.336ff.3b187540@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/15 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f629ee03fa788d94fd5865eb49848a5b66d5c6ae commit f629ee03fa788d94fd5865eb49848a5b66d5c6ae Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2025-11-25 13:48:29 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2025-12-11 09:22:22 +0000 libpfctl: improve error handling If we fail to open /dev/pf don't try to close it again. That would result in errno getting overwritten by close(), hiding potentially useful information. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 238ad591da9eede122a708be925b6b6a20e9046b) --- lib/libpfctl/libpfctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 8dea373d8941..0b3bb25163b8 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -76,7 +76,6 @@ pfctl_open(const char *pf_device) struct pfctl_handle *h; h = calloc(1, sizeof(struct pfctl_handle)); - h->fd = -1; h->fd = open(pf_device, O_RDWR); if (h->fd < 0) @@ -87,7 +86,8 @@ pfctl_open(const char *pf_device) return (h); error: - close(h->fd); + if (h->fd != -1) + close(h->fd); snl_free(&h->ss); free(h);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?693a8e20.336ff.3b187540>
