🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1496

gnu make bug

#1496
From: wsd
Date: Mon, 20 Feb 1989 00:37
48 lines
1796 bytes
I am running on a sun4-110 running sunos4.0
My version of gnu make has the following version info:

	GNU Make version 3.05, by Richard Stallman and Roland McGrath.
	Copyright (C) 1988 Free Software Foundation, Inc.
	This is free software; see the source for copying conditions.
	There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
	PARTICULAR PURPOSE.

when I give it this makefile (the file is named crasher):

	cfiles = $(wildcard *.c)
	
	test:   ;
		echo cfiles  $(cfiles)

I get the following output:

	./make -f crasher

	echo cfiles
	cfiles

This is incorrect, as there are several .c files in the current
directory (I am running in the gnu make source directory).

When we examined the code, the bug raised its ugly head in
glob.c:glob_filename on line 432.

	directory_name = (char *)alloca (i);

where i is 0.  alloca returns the same value as it returned the
last time it was called (the previous line, when filename) was
allocated.  Then on line 448

	directory_name[i] = '\0';

since directory_name really points to filename, filename gets trashed.
Even if i is not 0, since directory_name has exactly i bytes allocated
to it, directory_name[i] is out of bounds.  For some reason this
works on a sun 3.

The correction we made (which works so far) is to change line 432 to
read
	  directory_name = (char *)alloca (i + 1);


Scott Draves and Nick Thompson
Technical Details
Message-ID: <8902200037.AA26815@pitman.cs.brown.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.BROWN.EDU!wsd

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.BROWN.EDU!wsd
From: wsd@CS.BROWN.EDU
Newsgroups: gnu.utils.bug
Subject: gnu make bug
Message-ID: <8902200037.AA26815@pitman.cs.brown.edu>
Date: 20 Feb 89 00:37:00 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 48