From nobody@FreeBSD.org  Thu Oct 11 07:49:24 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 80319E5D
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 11 Oct 2012 07:49:24 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 69B678FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 11 Oct 2012 07:49:24 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9B7nNI0050114
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 11 Oct 2012 07:49:23 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q9B7nNK5050113;
	Thu, 11 Oct 2012 07:49:23 GMT
	(envelope-from nobody)
Message-Id: <201210110749.q9B7nNK5050113@red.freebsd.org>
Date: Thu, 11 Oct 2012 07:49:23 GMT
From: Erik Cederstrand <erik@cederstrand.dk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Null function pointer in ipfilter
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172599
>Category:       kern
>Synopsis:       [ipfilter] [patch] Null function pointer in ipfilter
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cy
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 11 11:49:20 UTC 2012
>Closed-Date:    Fri Jan 17 06:42:30 UTC 2014
>Last-Modified:  Fri Jan 17 06:42:30 UTC 2014
>Originator:     Erik Cederstrand
>Release:        CURRENT
>Organization:
>Environment:
>Description:
Based on Clang Static Analyzer report http://scan.freebsd.your.org/freebsd-head/LATEST/sbin/report-ivw4lE.html.gz#EndPath

There seems to be a case of inverse logic. The comment lines 2085- 2088 says the function should only be called if it is a valid pointer, but the opposite happens.
>How-To-Repeat:

>Fix:
Swap the logic. This is in line with a similar condition in line 2319.

Patch attached with submission follows:

Index: head/sys/contrib/ipfilter/netinet/fil.c
===================================================================
--- head/sys/contrib/ipfilter/netinet/fil.c	(revision 241370)
+++ head/sys/contrib/ipfilter/netinet/fil.c	(working copy)
@@ -2091,7 +2091,7 @@
			frentry_t *frs;

			ATOMIC_INC64(fr->fr_hits);
-			if ((fr->fr_func != NULL) &&
+			if ((fr->fr_func == NULL) ||
			    (fr->fr_func == (ipfunc_t)-1))
				continue;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Thu Oct 11 14:12:28 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172599 
Responsible-Changed-From-To: eadler->freebsd-bugs 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Thu Jan 31 13:58:04 UTC 2013 
Responsible-Changed-Why:  
sorry I held on to this for so long;   at the moment I have no time to 
look at this PR so return to the pool 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172599 
Responsible-Changed-From-To: freebsd-bugs->cy 
Responsible-Changed-By: cy 
Responsible-Changed-When: Wed Jul 3 05:23:56 UTC 2013 
Responsible-Changed-Why:  
Assign to myself. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172599 
State-Changed-From-To: open->closed 
State-Changed-By: cy 
State-Changed-When: Fri Jan 17 06:41:17 UTC 2014 
State-Changed-Why:  
Resolved in IP Filter 5.1.2 (in 10.0+). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172599 
>Unformatted:
