From 1bfe195143ffb6832ac6702e281964541554fcb3 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Thu, 28 Mar 2024 14:10:15 -0700 Subject: [PATCH] pfilctl: fix 'pfilctl hooks' when nothing is connected The 'hooks' command actually worked accidentially until now. It used PFILIOC_LISTHEADS to determine current number of hooks. This worked when at least one head had a hook connected to it. --- sbin/pfilctl/pfilctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/pfilctl/pfilctl.c b/sbin/pfilctl/pfilctl.c index 268f5a8d0e70..1af2190072b6 100644 --- a/sbin/pfilctl/pfilctl.c +++ b/sbin/pfilctl/pfilctl.c @@ -150,8 +150,8 @@ listhooks(int argc __unused, char *argv[] __unused) u_int nhooks, i; plh.pio_nhooks = 0; - if (ioctl(dev, PFILIOC_LISTHEADS, &plh) != 0) - err(1, "ioctl(PFILIOC_LISTHEADS)"); + if (ioctl(dev, PFILIOC_LISTHOOKS, &plh) != 0) + err(1, "ioctl(PFILIOC_LISTHOOKS)"); retry: plh.pio_hooks = calloc(plh.pio_nhooks, sizeof(struct pfilioc_hook)); if (plh.pio_hooks == NULL)