Date: Wed, 27 Apr 2022 12:50:30 GMT 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: a99ef04e0659 - stable/13 - pf: counter argument to pfr_pool_get() may never be NULL Message-ID: <202204271250.23RCoUUB011774@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a99ef04e0659db80bcf85074c4d37c029f292fe2 commit a99ef04e0659db80bcf85074c4d37c029f292fe2 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2022-04-21 12:53:05 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2022-04-27 06:46:55 +0000 pf: counter argument to pfr_pool_get() may never be NULL Coverity points out that if counter was NULL when passed to pfr_pool_get() we could potentially end up dereferencing it. Happily all users of the function pass a non-NULL pointer. Enforce this by assertion and remove the pointless NULL check. Reported by: Coverity (CID 273309) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit efc64d02a62f3254ecc0b22fcbcb8f73a079669f) --- sys/netpfil/pf/pf_table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index a2afd5c24cff..42cd633f8411 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -2211,6 +2211,7 @@ pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter, int idx = -1, use_counter = 0; MPASS(pidx != NULL); + MPASS(counter != NULL); switch (af) { case AF_INET: @@ -2230,7 +2231,7 @@ pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter, return (-1); idx = *pidx; - if (counter != NULL && idx >= 0) + if (idx >= 0) use_counter = 1; if (idx < 0) idx = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204271250.23RCoUUB011774>