From traister@manta.mojozone.org  Sat Jan  3 06:52:56 1998
Received: from manta.mojozone.org (root@dffl0-5.gate.net [199.227.254.68])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id GAA14265
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 3 Jan 1998 06:52:54 -0800 (PST)
          (envelope-from traister@manta.mojozone.org)
Received: (from traister@localhost)
	by manta.mojozone.org (8.8.7/8.8.7) id JAA00444;
	Sat, 3 Jan 1998 09:52:52 -0500 (EST)
Message-Id: <199801031452.JAA00444@manta.mojozone.org>
Date: Sat, 3 Jan 1998 09:52:52 -0500 (EST)
From: Joe Traister <traister@mojozone.org>
Reply-To: traister@mojozone.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: timed rejects valid networks with -n
X-Send-Pr-Version: 3.2

>Number:         5419
>Category:       bin
>Synopsis:       [PATCH] timed rejects valid networks with -n
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan  3 07:00:01 PST 1998
>Closed-Date:    Tue Nov 12 10:14:37 PST 2002
>Last-Modified:  Tue Nov 12 10:14:37 PST 2002
>Originator:     Joe Traister
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
None
>Environment:

	FreeBSD-2.2.2 through FreeBSD-current

>Description:

	When given -n followed by a network name or number, timed exits with
	"timed: no network usable".  This is due to the fact that
	getnetbyname(3) returns a struct with network numbers in host byte
	order, rather than network byte order.  This is correct behavior for
	getnetbyname(3) according to its man page.

>How-To-Repeat:

	timed -n <network>

	where <network> is a valid, directly-connected network address.

>Fix:

--- timed.c.dist	Fri Jan  2 22:14:01 1998
+++ timed.c	Fri Jan  2 22:14:25 1998
@@ -364,7 +364,7 @@
 				nentp = getnetbyaddr(nt->net, AF_INET);
 		}
 		if (nentp != 0) {
-			nt->net = nentp->n_net;
+			nt->net = htonl(nentp->n_net);
 		} else if (nt->net == INADDR_NONE) {
 			fprintf(stderr, "timed: unknown net %s\n", nt->name);
 			exit(1);

>Release-Note:
>Audit-Trail:

From: Steve Price <sprice@hiwaay.net>
To: traister@mojozone.org
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/5419: timed rejects valid networks with -n
Date: Sat, 03 Jan 1998 13:50:02 -0600

 Joe Traister wrote:
 > 
 > >Fix:
 > 
 > --- timed.c.dist        Fri Jan  2 22:14:01 1998
 > +++ timed.c     Fri Jan  2 22:14:25 1998
 > @@ -364,7 +364,7 @@
 >                                 nentp = getnetbyaddr(nt->net, AF_INET);
 >                 }
 >                 if (nentp != 0) {
 > -                       nt->net = nentp->n_net;
 > +                       nt->net = htonl(nentp->n_net);
 >                 } else if (nt->net == INADDR_NONE) {
 >                         fprintf(stderr, "timed: unknown net %s\n", nt->name);
 >                         exit(1);
 
 I am no timed(8) expert.  In fact, I have never used it.  Just from
 looking at the code it appears that if the above fix is appropriate
 then it should also be supplemented with the following patch.  I'm
 just guessing here, so don't shoot me if I'm wrong. :)
 
 Steve
 
 @@ -420,7 +420,7 @@
  		ntp->dest_addr.sin_port = port;
  
  		for (nt = nets; nt; nt = nt->next) {
 -			if (ntp->net.s_addr == htonl(nt->net))
 +			if (ntp->net.s_addr == nt->net)
  				break;
  		}
  		if ((nflag && !nt) || (iflag && nt))
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Thu Apr 30 22:36:03 PDT 1998 
State-Changed-Why:  
waiting for a committer... 
State-Changed-From-To: suspended->closed 
State-Changed-By: jhb 
State-Changed-When: Tue Nov 12 10:12:08 PST 2002 
State-Changed-Why:  
Not a bug.  timed -n works fine as it is.  Note that the network '127' is 
not valid however.  The timed code relies on nt->net being in host byte 
order later on in the loop when it uses shifts to adjust networks such as 
0x0000007f (127) to 0x7f000000 (127.0.0.0).  Later on when comparing network 
addresses htonl() is already used as noted in the follow-up e-mail. 

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