Bug in MAKE - (nf)

utzoo!decvax!pur-ee!ks utzoo!decvax!pur-ee!ks
Sun Jul 18 01:00:23 AEST 1982


#N:pur-ee:3400001:000:1608
pur-ee!ks    Jul 17 14:21:00 1982

In case you didn't get this in net.4bsd-bugs..
(Why are there 2 newsgroup names for the same thing?)

The MAKE program seemed to be having trouble with libraries.  Libraries
would ALWAYS be remade as if they were out of date.  Well, with a little
effort the problem was tracked to the Berkeley ASCII archive format.
The file names in archives are padded with spaces, and the comparison failed
with a NULL terminated string.  The file could never be found in the
library so it was considered not to exist.. thus it needed to be 'made' again.
This can be fixed pretty easily by adding the following lines to getarch()
in files.c:


getarch()
{
	struct ar_hdr arhead;
	long atol();
!!!!	char *s;

arpos += (arflen + 1) & ~1L;	/* round archived file length up to even */
if(arpos >= arlen)
	return(0);
fseek(arfd, arpos, 0);

	fread( (char *) &arhead, sizeof(arhead), 1, arfd);
	arpos += sizeof(arhead);
!!!!	strncpy(arfname, arhead.ar_name, sizeof(arhead.ar_name));     <--
#ifdef ASCARCH								|
	arflen = atol(arhead.ar_size);					|
	arfdate = atol(arhead.ar_date);					|
!!!!	for (s=arfname+sizeof(arhead.ar_name)-1;*s == ' ';s--)		|
!!!!		*s = CNULL;						|
#else									|
	arflen = arhead.ar_size;					|
	arfdate = arhead.ar_date;					|
#endif									|
xxxx	strncpy(arfname, arhead.ar_name, sizeof(arhead.ar_name));  >-----
return(1);
}


"!!!!" means lines that are added...
"xxxx" means lines that are deleted...

Move the strncpy() before the #ifdef'ed stuff and throw in the for loop
to make sure arfname becomes properly NULL terminated.

					Kirk Smith & Malcolm Slaney
					Purdue EE
----------




More information about the Comp.bugs.4bsd.ucb-fixes mailing list