Date: Tue, 25 Nov 2025 13:50:20 +0000 From: Kristof Provost <kp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 238ad591da9e - main - libpfctl: improve error handling Message-ID: <6925b41c.2d192.726c8765@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=238ad591da9eede122a708be925b6b6a20e9046b commit 238ad591da9eede122a708be925b6b6a20e9046b Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2025-11-25 13:48:29 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2025-11-25 13:50:09 +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") --- 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 e747763ae6ef..3db596d6fd38 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);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6925b41c.2d192.726c8765>
