From nobody@FreeBSD.org  Mon Apr  3 23:36:15 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 17B9216A44C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Apr 2006 23:36:15 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D7CBE43D45
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Apr 2006 23:36:14 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k33NaEtt019873
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 3 Apr 2006 23:36:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k33NaEOX019872;
	Mon, 3 Apr 2006 23:36:14 GMT
	(envelope-from nobody)
Message-Id: <200604032336.k33NaEOX019872@www.freebsd.org>
Date: Mon, 3 Apr 2006 23:36:14 GMT
From: Bruce Becker <hostmaster@whois.gts.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: amd64 inetd returns 8 byte time value instead of 4 byte
X-Send-Pr-Version: www-2.3

>Number:         95290
>Category:       bin
>Synopsis:       [patch] on amd64, inetd(8) returns 8 byte time value instead of 4 byte
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 03 23:40:15 GMT 2006
>Closed-Date:    Tue May 02 19:13:11 GMT 2006
>Last-Modified:  Tue May 02 19:13:11 GMT 2006
>Originator:     Bruce Becker
>Release:        FreeBSD 6.0-STABLE amd64
>Organization:
GTS
>Environment:
FreeBSD indra 6.0-STABLE FreeBSD 6.0-STABLE #2: Thu Jan 12 15:28:18 EST 2006     root@indra:/usr/obj/usr/src/sys/INDRA  amd64
>Description:

according to RFC768 the value to be returend to a "time" query is an int32
object, but amd64 (& likely other 64-bit ports) returns 8 bytes with
trailing nulls

>How-To-Repeat:
Enable the "time" builtin in inetd.conf, then "telnet localhost time > xxx" -
the last line of "xxx" will contain the erroneous 8 byte result


>Fix:

--- builtins.c.2002072200       Mon Jul 22 09:58:58 2002
+++ builtins.c  Mon Apr  3 18:04:00 2006
@@ -64,7 +64,7 @@
 void           iderror(int, int, int, const char *);
 void           ident_stream(int, struct servtab *);
 void           initring(void);
-unsigned long  machtime(void);
+unsigned int   machtime(void);
 void           machtime_dg(int, struct servtab *);
 void           machtime_stream(int, struct servtab *);
 
@@ -685,7 +685,7 @@
  * some seventy years Bell Labs was asleep.
  */
 
-unsigned long
+unsigned int
 machtime(void)
 {
        struct timeval tv;
@@ -696,7 +696,7 @@
                return (0L);
        }
 #define        OFFSET ((u_long)25567 * 24*60*60)
-       return (htonl((long)(tv.tv_sec + OFFSET)));
+       return (htonl((unsigned int)(tv.tv_sec + OFFSET)));
 #undef OFFSET
 }
 
@@ -704,7 +704,7 @@
 void
 machtime_dg(int s, struct servtab *sep)
 {
-       unsigned long result;
+       unsigned int result;
        struct sockaddr_storage ss;
        socklen_t size;
 
@@ -725,7 +725,7 @@
 void
 machtime_stream(int s, struct servtab *sep __unused)
 {
-       unsigned long result;
+       unsigned int result;
 
        result = machtime();
        (void) send(s, (char *) &result, sizeof(result), MSG_EOF);

>Release-Note:
>Audit-Trail:

From: hotlips Internet admin <hostmaster@GTS.NET>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: misc/95290: amd64 inetd returns 8 byte time value instead of 4 byte
Date: Mon, 3 Apr 2006 20:41:34 -0400 (EDT)

 Thus saith FreeBSD-gnats-submit@FreeBSD.org:
 | 
 | Thank you very much for your problem report.
 | It has the internal identification `misc/95290'.
 | The individual assigned to look at your
 | report is: freebsd-bugs. 
 | 
 | You can access the state of your problem report at any time
 | via this link:
 | 
 | http://www.freebsd.org/cgi/query-pr.cgi?pr=95290
 | 
 | >Category:       misc
 | >Responsible:    freebsd-bugs
 | >Synopsis:       amd64 inetd returns 8 byte time value instead of 4 byte
 | >Arrival-Date:   Mon Apr 03 23:40:15 GMT 2006
 
 
 	A minor nit: it's RFC 738 (not 768)
 
 
 -- 
 Bruce Becker			+1 416 410 0879
 GTS Network Administration	Toronto, Ont.
 Email:	hostmaster@whois.gts.net

From: Kris Kennaway <kris@obsecurity.org>
To: Bruce Becker <hostmaster@whois.gts.net>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/95290: amd64 inetd returns 8 byte time value instead of 4 byte
Date: Tue, 4 Apr 2006 13:59:44 -0400

 --liOOAslEiF7prFVr
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Mon, Apr 03, 2006 at 11:36:14PM +0000, Bruce Becker wrote:
 
 > >How-To-Repeat:
 > Enable the "time" builtin in inetd.conf, then "telnet localhost time > xxx" -
 > the last line of "xxx" will contain the erroneous 8 byte result
 
 There's also an argument that the RFC is broken since 64-bit time_t is
 the way of the future (i.e. the RFC is not Y2.038K compliant and will
 need to be amended anyway).
 
 Kris
 --liOOAslEiF7prFVr
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.2.2 (FreeBSD)
 
 iD8DBQFEMrQQWry0BWjoQKURAuZ1AKDkTlquWz5yl3PpR6X+hzfVwPQFUQCffm+l
 U/soAWbyxayG1c1W+R6/0JM=
 =in/h
 -----END PGP SIGNATURE-----
 
 --liOOAslEiF7prFVr--

From: hotlips Internet admin <hostmaster@GTS.NET>
To: kris@obsecurity.org (Kris Kennaway)
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/95290: amd64 inetd returns 8 byte time value instead of 4 byte
Date: Tue, 4 Apr 2006 14:37:33 -0400 (EDT)

 Thus saith Kris Kennaway:
 | 
 | 
 | --liOOAslEiF7prFVr
 | Content-Type: text/plain; charset=us-ascii
 | Content-Disposition: inline
 | 
 | On Mon, Apr 03, 2006 at 11:36:14PM +0000, Bruce Becker wrote:
 | 
 | > >How-To-Repeat:
 | > Enable the "time" builtin in inetd.conf, then "telnet localhost time > xxx" -
 | > the last line of "xxx" will contain the erroneous 8 byte result
 | 
 | There's also an argument that the RFC is broken since 64-bit time_t is
 | the way of the future (i.e. the RFC is not Y2.038K compliant and will
 | need to be amended anyway).
 
 
 	Of course you are right, but i need to get my NetApp
 	time synchronised properly in the meantime :) ...
 
 
 -- 
 Bruce Becker			+1 416 410 0879
 GTS Network Administration	Toronto, Ont.
 Email:	hostmaster@gts.net
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Sat Apr 8 22:46:25 UTC 2006 
Responsible-Changed-Why:  
I'll take a look at this - I want to see if there are other types 
that might match the protocol more closely before committing the 
patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95290 
State-Changed-From-To: open->patched 
State-Changed-By: dwmalone 
State-Changed-When: Mon Apr 17 18:36:07 UTC 2006 
State-Changed-Why:  
I've committed a fix to -current and will merge it to RELENG_[456] 
in two weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95290 
State-Changed-From-To: patched->closed 
State-Changed-By: dwmalone 
State-Changed-When: Tue May 2 19:12:33 UTC 2006 
State-Changed-Why:  
It should now be fixed in 4, 5 and 6. Thanks for the PR, 

David. 

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