Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site psivax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!tektronix!hplabs!sdcrdcf!psivax!friesen From: friesen@psivax.UUCP (Stanley Friesen) Newsgroups: net.sources.bugs Subject: Subtle bug in rcs Message-ID: <866@psivax.UUCP> Date: Mon, 18-Nov-85 17:37:39 EST Article-I.D.: psivax.866 Posted: Mon Nov 18 17:37:39 1985 Date-Received: Sat, 7-Dec-85 04:31:22 EST Reply-To: friesen@psivax.UUCP (Stanley Friesen) Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 71 DESCRIPTION: On BSD 4.2 systems (and presumably 4.3) 'rcs' may incorrectly set the file access and modification times. This is due to an invalid assumption about the stability of the fields in a 'struct stat'. The code as it exists assumes that st_mtime will always follow immediately after st_atime. This is *not* true on BSD 4.2. The bug will only appear if the command has been compiled with the -DVARIAN option. REPEAT BY: Choose an RCS file to play with. Then do the following: rcs -l filename ls -l filename,v the result will be: -r--r--r-- 1 user 48802 Feb 5 206 filename,v FIX: A context diff of the fix follows ------------------------CUT HERE----------------------------------------- *** rcs.c.old Mon Nov 18 14:08:15 1985 --- rcs.c Mon Nov 18 14:08:20 1985 *************** *** 164,169 struct Status * curstate; struct hshentry * target; struct access *temp, *temptr; nerror = 0; catchints(); --- 164,172 ----- struct Status * curstate; struct hshentry * target; struct access *temp, *temptr; + #ifdef VARIAN + time_t timep[2]; /* Temporary for utime call */ + #endif VARIAN nerror = 0; catchints(); *************** *** 521,527 { if (chmod(RCSfilename,filestatus.st_mode & ~0222)<0) warn("Can't set mode of %s",RCSfilename); ! utime(RCSfilename,&filestatus.st_atime); } #else if (chmod(RCSfilename,filestatus.st_mode & ~0222)<0) --- 524,532 ----- { if (chmod(RCSfilename,filestatus.st_mode & ~0222)<0) warn("Can't set mode of %s",RCSfilename); ! timep[0] = filestatus.st_atime; ! timep[1] = filestatus.st_mtime; ! utime(RCSfilename,timep); } #else if (chmod(RCSfilename,filestatus.st_mode & ~0222)<0) -- Sarima (Stanley Friesen) UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen ARPA: ttidca!psivax!friesen@rand-unix.arpa