Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Jan 2000 04:50:03 -0800 (PST)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/15981: rcp -p fails when times have high bit set
Message-ID:  <200001081250.EAA84657@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/15981; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: klh@netcom.com
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/15981: rcp -p fails when times have high bit set
Date: Sat, 8 Jan 2000 23:49:24 +1100 (EST)

 On Sat, 8 Jan 2000 klh@netcom.com wrote:
 
 > >Description:
 > This code fragment should be using %ul instead of %ld for both fields.
 > 
 > 	if (pflag) {
 > 		(void)snprintf(path, sizeof(path), "T%ld 0 %ld 0\n",
 > 		    (long)statp->st_mtimespec.tv_sec,
 > 		    (long)statp->st_atimespec.tv_sec);
 > 		(void)write(rem, path, strlen(path));
 
 Not under systems with signed time_t like FreeBSD.  Using %ul would
 break times before the epoch (about 1970).
 
 > >How-To-Repeat:
 > Create a file with a st_mtime that has the high bit set.  Attempt
 > to copy it with "rcp -p foo target:."
 > where target is a 64-bit system such as an Alpha (running D/U in this
 > case).  Will fail with a "mtime.sec not delimited" screwup message
 > due to presence of a minus sign.
 
 This seems to be a defect in D/U :-).  An st_mtime with the high bit set
 is negative.  Negative times give undefined behaviour in POSIX.1.  FreeBSD
 supports them, but actually using them gives interoperability problems like
 the one you noticed.
 
 > >Fix:
 
 Don't create files with an st_mtime that is before the epoch.
 
 Related bugs:
 
 FreeBSD's rcp.c lacks range checking of times sent by the target system.
 Large times are silently truncated to (time_t)LONG_MAX, i.e., to LONG_MAX
 on i386's and -1 on alphas.  Large negative times are silently truncated
 to (time_t)LONG_MIN, i.e., to LONG_MIN on i386's and 0 on alphas.
 
 Bruce
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001081250.EAA84657>