From thomas@cuivre.fr.eu.org  Fri Jul 30 16:31:47 2010
Return-Path: <thomas@cuivre.fr.eu.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 54495106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 30 Jul 2010 16:31:47 +0000 (UTC)
	(envelope-from thomas@cuivre.fr.eu.org)
Received: from melamine.cuivre.fr.eu.org (unknown [IPv6:2001:470:1f15:1531:224:e8ff:fe3d:60a5])
	by mx1.freebsd.org (Postfix) with ESMTP id 17DE48FC08
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 30 Jul 2010 16:31:47 +0000 (UTC)
Received: by melamine.cuivre.fr.eu.org (Postfix, from userid 1000)
	id 6F323261C; Fri, 30 Jul 2010 18:31:46 +0200 (CEST)
Message-Id: <20100730163146.6F323261C@melamine.cuivre.fr.eu.org>
Date: Fri, 30 Jul 2010 18:31:46 +0200 (CEST)
From: Thomas Quinot <thomas@cuivre.fr.eu.org>
Reply-To: Thomas Quinot <thomas@cuivre.fr.eu.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: in_pcbbind: redundant test
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         149117
>Category:       kern
>Synopsis:       [inet] [patch] in_pcbbind: redundant test
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-net
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 30 16:40:06 UTC 2010
>Closed-Date:    Thu May 01 09:27:00 UTC 2014
>Last-Modified:  Thu May 01 09:27:00 UTC 2014
>Originator:     Thomas Quinot
>Release:        FreeBSD 8.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD melamine.cuivre.fr.eu.org 8.0-STABLE FreeBSD 8.0-STABLE #0: Sun Mar 28 14:46:11 CEST 2010 thomas@melamine.cuivre.fr.eu.org:/usr/obj/usr/src/sys/GENERIC amd64


	
>Description:
	in_pcbbind has a redundant test for inp->inp_lport == 0:
	if this is not true, the if statement just above will have
	caused an early return with EINVAL.

>How-To-Repeat:
	Found by code reading. No observable effect.
>Fix:

Index: in_pcb.c
===================================================================
--- in_pcb.c	(rvision 210660)
+++ in_pcb.c	(copie de travail)
@@ -296,8 +296,7 @@
 
 	if (inp->inp_lport != 0 || inp->inp_laddr.s_addr != INADDR_ANY)
 		return (EINVAL);
-	anonport = inp->inp_lport == 0 && (nam == NULL ||
-	    ((struct sockaddr_in *)nam)->sin_port == 0);
+	anonport = nam == NULL || ((struct sockaddr_in *)nam)->sin_port == 0;
 	error = in_pcbbind_setup(inp, nam, &inp->inp_laddr.s_addr,
 	    &inp->inp_lport, cred);
 	if (error)


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Jul 30 17:41:19 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149117 
State-Changed-From-To: open->closed 
State-Changed-By: thomas 
State-Changed-When: Thu May 1 09:26:05 UTC 2014 
State-Changed-Why:  
Fixed by np in rev. r245914 on 2013-01-25 

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