From nobody Thu Dec 11 09:25:52 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dRnJK0WB7z6Kf4q for ; Thu, 11 Dec 2025 09:25:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dRnJJ6j01z3f8Q for ; Thu, 11 Dec 2025 09:25:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765445152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bB4P5isZmJy8YsOpP+g9zIDTLcSLW1dLj/Yx+/gSUIk=; b=JgatSw0dZnPMH1F9uJTkQCdo4u5rWveGG8qYGaWbt/0NPNAsgQhY1qeckCBCLbkxey8uEI +DlBv6VZP/9DZzCLq4a/epHgrLMzn8yfr52qnDlqTG1mAP69t5ILoJk6be6FeRdjwPP4Gn /+YSqIz7N3Sm997AJQDsdkD58eTZuVnQ52wqUuujeicwtjeJ7PgFF2a9OzobDbLMS8nCez kMdPLX/s06wsjfHaEfjCJqZ2VBY9TCOlynSm4Dk4cpmMVvsZkPWX2lbUFuEEJ8oMU/1pXC hw4d3fWtROHtTwT7YnJTHIVeaJQ+HvKCs2i0I84davDIgJDdc4iXPQPPthPKCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765445152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bB4P5isZmJy8YsOpP+g9zIDTLcSLW1dLj/Yx+/gSUIk=; b=j/3j0kqyW41FxnnMrNYoSV8blkOAmt3ITNECZ7mKYk2deuWypQenZQrnw7+b9GEXbxgoFD NI32iLruIYbl7WygexEyMDe4EdAlaBwgm+0U4AW+EgHdQqXhkC9neK9N1zry5VtZBEK51E 9gd678KfY2+/1boIjwpXc9uu0FYSC4ww6M95lGV95JMLotkGWtFnhmehsbJcqBhJ9gE3+T f+H9MSiZeO/YYgi5Ppw5NBOdfcedx1BzuFIWOnbqn2KiZe1hkjvTS8EReXdhTxmtbL5AI9 UjDSGAw4dQM9hWgPZpCM/ceMxts/TXoPuxzjbeBYcjmsRa3VjKfvjWqEDj+7gQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765445152; a=rsa-sha256; cv=none; b=r6IwflTp4gH5IFXKqWyfswhgU2qUhtSMa6S8bzB9Rc5jHQzricZC2oBxqE0GIrYwoBgBWa S8I7ZTFc5a1CV8Bh6wVKkwSiVmKALr337k2KFDLL3lY/oK1nuV7xAGmHysVbogQUtO+7KX 1Mz+6ILsaBp680mD4Lx+SFodEptb5ZFtls8XAOeujZoNPvFAvODj7jAse8KZasVKKdSkus +W53R81x+CIfZS02MyMiLzWSKA0/x3OjIGRfKHvq/tldZJKj8mQZkKtPOpDhDARo3WHClA cMSoxHUfs8eeJZUMeW943R5hO2j4yR+WH+IfRHUCIZFXQn9vw7JHCSwCp9L9mg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dRnJJ6Jwyz984 for ; Thu, 11 Dec 2025 09:25:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 336ff by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 11 Dec 2025 09:25:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: f629ee03fa78 - stable/15 - libpfctl: improve error handling List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: f629ee03fa788d94fd5865eb49848a5b66d5c6ae Auto-Submitted: auto-generated Date: Thu, 11 Dec 2025 09:25:52 +0000 Message-Id: <693a8e20.336ff.3b187540@gitrepo.freebsd.org> The branch stable/15 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f629ee03fa788d94fd5865eb49848a5b66d5c6ae commit f629ee03fa788d94fd5865eb49848a5b66d5c6ae Author: Kristof Provost AuthorDate: 2025-11-25 13:48:29 +0000 Commit: Kristof Provost 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);