From daniel+roe=marvin@roe.ch  Thu Apr 16 13:12:46 2009
Return-Path: <daniel+roe=marvin@roe.ch>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2B9E01065675
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Apr 2009 13:12:46 +0000 (UTC)
	(envelope-from daniel+roe=marvin@roe.ch)
Received: from calvin.ustdmz.roe.ch (calvin.ustdmz.roe.ch [IPv6:2001:41e0:ff17:face::26])
	by mx1.freebsd.org (Postfix) with ESMTP id 19EE68FC0C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Apr 2009 13:12:45 +0000 (UTC)
	(envelope-from daniel+roe=marvin@roe.ch)
Received: from host-178-185.csnc.ch ([212.254.178.185] helo=marvin.ustcor.roe.ch)
	by calvin.ustdmz.roe.ch (envelope-from <daniel+roe=marvin@roe.ch>)
	with ESMTPSA (auth=roe) (TLSv1:AES256-SHA:256) id 1LuQjZ-000OCO-TD
	for FreeBSD-gnats-submit@freebsd.org; Thu, 16 Apr 2009 14:30:26 +0200
Received: from roe (uid 1001)
	(envelope-from roe@marvin.ustcor.roe.ch)
	id 45
	by marvin.ustcor.roe.ch (DragonFly Mail Agent)
	Thu, 16 Apr 2009 14:30:26 +0200
Message-Id: <E1LuQjZ-000OCO-TD@calvin.ustdmz.roe.ch>
Date: Thu, 16 Apr 2009 14:30:26 +0200
From: Daniel Roethlisberger <daniel@roe.ch>
Reply-To: Daniel Roethlisberger <daniel@roe.ch>
To: FreeBSD-gnats-submit@freebsd.org
Cc: daniel@roe.ch
Subject: [maintainer] security/nmap - fix ncat host resolver
X-Send-Pr-Version: 3.113
X-GNATS-Notify: daniel@roe.ch

>Number:         133779
>Category:       ports
>Synopsis:       [maintainer] security/nmap - fix ncat host resolver
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    wxs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 16 13:20:03 UTC 2009
>Closed-Date:    Tue Apr 21 15:37:12 UTC 2009
>Last-Modified:  Tue Apr 21 15:40:04 UTC 2009
>Originator:     Daniel Roethlisberger
>Release:        FreeBSD 7.1-RELEASE-p4 i386
>Organization:
>Environment:
System: FreeBSD marvin.ustcor.roe.ch 7.1-RELEASE-p4 FreeBSD 7.1-RELEASE-p4 #0: Sun Mar 22 12:35:36 UTC 2009 root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386
>Description:
Ncat uses getaddrinfo(3) to resolve hostnames and always passes it a numerical
service string.  FreeBSD getaddrinfo(3) until recently was broken with
numerical service strings (see PR bin/51827).  This patch adds a workaround for
FreeBSD versions with broken getaddrinfo(3), fixing Ncat where it is currently
unable to resolve any hostnames.

svn add files/patch-ncat__ncat_core.c
>How-To-Repeat:
ncat -v localhost 80
>Fix:
--- nmap-ncat-fix.diff begins here ---
diff -ruN nmap.orig/Makefile nmap/Makefile
--- nmap.orig/Makefile	2009-04-13 11:53:53.000000000 +0200
+++ nmap/Makefile	2009-04-16 13:33:54.000000000 +0200
@@ -7,6 +7,7 @@
 
 PORTNAME=	nmap
 DISTVERSION=	4.85BETA7
+PORTREVISION=	1
 CATEGORIES=	security ipv6
 MASTER_SITES=	http://nmap.org/dist/ \
 		http://www.mirrors.wiretapped.net/security/network-mapping/nmap/ \
diff -ruN nmap.orig/files/patch-ncat__ncat_core.c nmap/files/patch-ncat__ncat_core.c
--- nmap.orig/files/patch-ncat__ncat_core.c	1970-01-01 01:00:00.000000000 +0100
+++ nmap/files/patch-ncat__ncat_core.c	2009-04-16 14:12:56.000000000 +0200
@@ -0,0 +1,33 @@
+--- ncat/ncat_core.c.orig	2009-04-02 04:57:42.000000000 +0200
++++ ncat/ncat_core.c	2009-04-16 14:12:39.000000000 +0200
+@@ -11,6 +11,7 @@
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #endif
++#include <sys/param.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+@@ -96,13 +97,22 @@
+   rc = Snprintf(portbuf, sizeof(portbuf), "%hu", port);
+   assert(rc >= 0 && rc < sizeof(portbuf));
+ 
++#if (defined(__FreeBSD_version) && (__FreeBSD_version < 800075) \
++    && ((__FreeBSD_version > 800000) || (__FreeBSD_version < 702000)))
++  rc = getaddrinfo(hostname, "domain", &hints, &result);
++#else
+   rc = getaddrinfo(hostname, portbuf, &hints, &result);
++#endif
+   if (rc != 0 || result == NULL)
+       return 0;
+   assert(result->ai_addrlen > 0 && result->ai_addrlen <= (int) sizeof(struct sockaddr_storage));
+   *sslen = result->ai_addrlen;
+   memcpy(ss, result->ai_addr, *sslen);
+   freeaddrinfo(result);
++#if (defined(__FreeBSD_version) && (__FreeBSD_version < 800075) \
++    && ((__FreeBSD_version > 800000) || (__FreeBSD_version < 702000)))
++  ((struct sockaddr_in *)ss)->sin_port = htons(port);
++#endif
+   return 1;
+ }
+ 
--- nmap-ncat-fix.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->wxs 
Responsible-Changed-By: wxs 
Responsible-Changed-When: Thu Apr 16 14:02:02 UTC 2009 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133779 

From: Wesley Shields <wxs@FreeBSD.org>
To: Daniel Roethlisberger <daniel@roe.ch>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/133779: [maintainer] security/nmap - fix ncat host
	resolver
Date: Thu, 16 Apr 2009 10:04:35 -0400

 If I am reading this patch correctly this does not apply to the upcoming
 7.2 release.  If this is incorrect please let me know so I can get
 portmgr approval to commit it, otherwise it will wait until after the
 freeze is over.
 
 -- WXS

From: Daniel Roethlisberger <daniel@roe.ch>
To: Wesley Shields <wxs@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/133779: [maintainer] security/nmap - fix ncat host resolver
Date: Thu, 16 Apr 2009 17:00:36 +0200

 Wesley Shields <wxs@FreeBSD.org> 2009-04-16:
 > If I am reading this patch correctly this does not apply to the
 > upcoming 7.2 release.  If this is incorrect please let me know
 > so I can get portmgr approval to commit it, otherwise it will
 > wait until after the freeze is over.
 
 Correct.  RELENG_7_2 has the fixed getaddrinfo(3); the Ncat patch
 is only required for compatibility with 7.1 and earlier release
 branches (and 8.0 before the end of March 2009).  I should have
 stated that more clearly.
 
 -- 
 Daniel Roethlisberger
 http://daniel.roe.ch/

From: Wesley Shields <wxs@FreeBSD.org>
To: Daniel Roethlisberger <daniel@roe.ch>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/133779: [maintainer] security/nmap - fix ncat host
	resolver
Date: Thu, 16 Apr 2009 11:23:09 -0400

 On Thu, Apr 16, 2009 at 05:00:36PM +0200, Daniel Roethlisberger wrote:
 > Wesley Shields <wxs@FreeBSD.org> 2009-04-16:
 > > If I am reading this patch correctly this does not apply to the
 > > upcoming 7.2 release.  If this is incorrect please let me know
 > > so I can get portmgr approval to commit it, otherwise it will
 > > wait until after the freeze is over.
 > 
 > Correct.  RELENG_7_2 has the fixed getaddrinfo(3); the Ncat patch
 > is only required for compatibility with 7.1 and earlier release
 > branches (and 8.0 before the end of March 2009).  I should have
 > stated that more clearly.
 
 Great, thank you for the clarification.  I will queue this up to go into
 the tree after the freeze has ended.  Thank you for your work on this.
 
 -- WXS
State-Changed-From-To: open->closed 
State-Changed-By: wxs 
State-Changed-When: Tue Apr 21 15:37:11 UTC 2009 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133779 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/133779: commit references a PR
Date: Tue, 21 Apr 2009 15:37:05 +0000 (UTC)

 wxs         2009-04-21 15:36:56 UTC
 
   FreeBSD ports repository
 
   Modified files:
     security/nmap        Makefile 
   Added files:
     security/nmap/files  patch-ncat__ncat_core.c 
   Log:
   - Add patch to work around versions of FreeBSD with broken
     getaddrinfo(3) (7.1 and earlier, and -CURRENT before the end of March
     2009).
   
   PR:             ports/133779
   Submitted by:   Daniel Roethlisberger <daniel@roe.ch> (maintainer)
   
   Revision  Changes    Path
   1.115     +1 -0      ports/security/nmap/Makefile
   1.1       +33 -0     ports/security/nmap/files/patch-ncat__ncat_core.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
