🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #834

Bug in make 3.62

#834
From: Eric Youngdale
Date: Sun, 13 Sep 1992 01:06
41 lines
2140 bytes
	I have found a bug in make-3.62, which can result in make crashing
with a segmentation fault.  I am enclosing a patch which fixes this.

	Basically the problem is that if we do not check to make sure that
p[l] is within the actual string we are looking at, then p[l] could have any
value.  I ran across a situation under linux where the string was "CC=cc",
and when we got to the test for word1eq ("ifndef", 6), it looked at the
character which was just after the terminating null in "CC=cc", and this number
turned out to be negative.  When it got to the isblank test, it was looking
in the ctype array with a negative index, and as it turned out, this
led to a segmentation fault.

	To fix this, I simply added a test to make sure that (strlen(p) > l)

	It might also be a good idea to change the data type of p and p2 to be
unsigned, as well.

-Eric

*** read.c.~1~	Thu Sep 10 23:46:15 1992
--- read.c	Sat Sep 12 21:35:36 1992
***************
*** 331,338 ****
        if (*p == '\0' && lb.buffer[0] != '\t')
  	continue;

! #define	word1eq(s, l) 	((p[l] == '\0' || isblank (p[l])) && \
! 			 !strncmp (s, p, l))
        if (word1eq ("ifdef", 5) || word1eq ("ifndef", 6)
  	  || word1eq ("ifeq", 4) || word1eq ("ifneq", 5)
  	  || word1eq ("else", 4) || word1eq ("endif", 5))
--- 331,339 ----
        if (*p == '\0' && lb.buffer[0] != '\t')
  	continue;

! #define	word1eq(s, l) 	(strlen(p) > l &&
! 			 ((p[l] == '\0' || isblank (p[l])) && \
! 			  !strncmp (s, p, l)))
        if (word1eq ("ifdef", 5) || word1eq ("ifndef", 6)
  	  || word1eq ("ifeq", 4) || word1eq ("ifneq", 5)
  	  || word1eq ("else", 4) || word1eq ("endif", 5))
Technical Details
Message-ID: <9209130106.AA17347@tantalus.nrl.navy.mil>
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tantalus.nrl.navy.mil!eric

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tantalus.nrl.navy.mil!eric
From: eric@tantalus.nrl.navy.mil (Eric Youngdale)
Subject: Bug in  make 3.62
Message-ID: <9209130106.AA17347@tantalus.nrl.navy.mil>
Sender: gnulists@ai.mit.edu
Organization: Gnus Not Usenet
Distribution: gnu
Date: Sun, 13 Sep 1992 01:06:55 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 42