Date: Mon, 30 Jun 2025 15:00:54 GMT 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: eb6c2218fe64 - main - pfctl: Zap bits in host_v4(), use mask parameter Message-ID: <202506301500.55UF0scN047617@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=eb6c2218fe64451dff6bedde092b7a04db753a9c commit eb6c2218fe64451dff6bedde092b7a04db753a9c Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2025-06-27 12:17:23 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2025-06-30 15:00:28 +0000 pfctl: Zap bits in host_v4(), use mask parameter This avoids a duplicate strrchr() call and makes the function consistent with host_v6() regarding mask handling. While here, use the destination's size in memcpy instead of hardcoding its type. OK sashan Obtained from: OpenBSD, kn <kn@openbsd.org>, a7ede25358 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl_parser.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index d3017bbd2568..0c5f184106cd 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1885,11 +1885,10 @@ host_v4(const char *s, int mask) { struct node_host *h = NULL; struct in_addr ina; - int bits = 32; - memset(&ina, 0, sizeof(struct in_addr)); - if (strrchr(s, '/') != NULL) { - if ((bits = inet_net_pton(AF_INET, s, &ina, sizeof(ina))) == -1) + memset(&ina, 0, sizeof(ina)); + if (mask > -1) { + if (inet_net_pton(AF_INET, s, &ina, sizeof(ina)) == -1) return (NULL); } else { if (inet_pton(AF_INET, s, &ina) != 1) @@ -1902,7 +1901,7 @@ host_v4(const char *s, int mask) h->ifname = NULL; h->af = AF_INET; h->addr.v.a.addr.addr32[0] = ina.s_addr; - set_ipmask(h, bits); + set_ipmask(h, mask > -1 ? mask : 32); h->next = NULL; h->tail = h;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506301500.55UF0scN047617>