[4bsd-f77 #42] F77 can compile a file onto itself
4bsd-f77 at utah-cs.UUCP
4bsd-f77 at utah-cs.UUCP
Wed Sep 5 16:05:59 AEST 1984
From: Donn Seeley <donn at utah-cs.arpa>
Subject: F77 can compile a file onto itself
Index: usr.bin/f77/src/f77/f77.c 4.2BSD
Description:
If you ask f77 to compile onto the source file you gave it, it
will happily do so, leaving you to jump up and down and scream
and tear your hair out for having been so stupid.
Repeat-By:
To see how this works, run the following sequence of commands:
----------------------------------------------------------------
% echo ' end' > end.f
% file end.f
end.f: commands text
% f77 end.f -o end.f
end.f:
MAIN:
% file end.f
end.f: demand paged pure executable not stripped
%
----------------------------------------------------------------
Fix:
One way to fix this is to check the loader file to see if it
ends in a sensitive suffix; if it does, and the file exists,
complain and don't load. Here are the changes to f77.c to
cause this to happen:
----------------------------------------------------------------
*** /tmp/,RCSt1018021 Mon Aug 27 16:04:01 1984
--- f77.c Fri Aug 24 21:09:26 1984
***************
*** 454,459
break;
}
if(loadflag && !erred)
doload(loadargs, loadp);
done(erred);
--- 504,511 -----
break;
}
+ if( stupid(aoutname) )
+ erred = YES;
if(loadflag && !erred)
doload(loadargs, loadp);
done(erred);
***************
*** 962,967
clf(p)
FILEP *p;
{
--- 1012,1034 -----
+ stupid(s)
+ char *s;
+ {
+ char c;
+
+ if( (c = dotchar(aoutname))
+ && index("focsreF", c)
+ && access(aoutname, 0) == 0 )
+ {
+ fprintf(diagfile, "Loading on %s would destroy it\n", s);
+ return(YES);
+ }
+ return(NO);
+ }
+
+
+
clf(p)
FILEP *p;
{
----------------------------------------------------------------
Here is what f77 does after you install the changes:
----------------------------------------------------------------
% echo ' end' > end.f
% file end.f
end.f: commands text
% f77 end.f -o end.f
end.f:
MAIN:
Loading on end.f would destroy it
% file end.f
end.f: commands text
%
----------------------------------------------------------------
The gods themselves contend in vain,
Donn Seeley University of Utah CS Dept donn at utah-cs.arpa
40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list