bugmake - Bugs: bug #28748, "matches" array is...

 
 

bug #28748: "matches" array is improperly sized in implicit.c:pattern_search()

Submitted by:  None
Submitted on:  Thu 28 Jan 2010 12:10:50 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 3.81Operating System: Any
Fixed Release: 3.82Triage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 28 Jan 2010 07:22:28 AM UTC, comment #1:

This has already been fixed for the upcoming 3.82 release.

Boris Kolpackov <bosk>
Project Member
Thu 28 Jan 2010 12:10:50 AM UTC, original submission:

We just discovered that the bug described in the following e-mail thread (obtained by Googling "num_pattern_rules") exists in GNU Make 3.81 and was causing it to crash on Windows due to attempting to access memory off the end of the "matches" array. Note that both issues described below (sizing of "matches" and "checked_lastslash") are still incorrect in the 3.81 code base. Applying the suggested fixes eliminated the crashes and a careful reading/analysis of the code has convinced us of the correctness of the proposed change.

==========

Hi,

This bug also affects the variable checked_lastslash. The fix for this is to change
lines 137-138 of implicit.c to:

char *checked_lastslash
= (char ) alloca (num_pattern_rules max_pattern_targets
* sizeof (char));

Regards,

Ian

--
Ian Willis
Digital Broadcast Systems
Philips Semiconductors Systems Laboratory, Southampton
email: [EMAIL PROTECTED] tel: +44 (0)23 80702701

---------------------- Forwarded by Ian Willis/SOU/SC/PHILIPS on 11/07/2001 15:22
---------------------------

Ian Willis
11/07/2001 14:00

To: [EMAIL PROTECTED]@SMTP@EMEA2
cc:
Subject: implicit.c matches not allocated enough memory
Classification: Unclassified

Hi,

I believe I have found a bug in make version 3.79.1. I am running on Sparc/Solaris 8.
This bug exists in the distribution of gnu make with Solaris 8 (version 3.78.1) and in
the compiled binary package available at http://www.sunfreeware.com (3.79.1). With a
particular set of makefiles, I get a Segmentation Violation. I have traced this to the
pattern_search function of implicit.c line 133. This line allocates memory for storing
rule match indicies. Since a rule may be included in tryrules multiple times (see
comment on line 277), it is possible that more that num_pattern_rules elements are
stored in matches. In my case, nrules was being set to 17 whilst num_pattern_rules was
set to 16. Setting matches[16] was overwriting tryrules[0]. I believe that lines
132-133 should be replaced with:

unsigned int *matches
= (unsigned int ) alloca (num_pattern_rules max_pattern_targets
* sizeof (unsigned int));

This is similar to the allocation of tryrules (which has the same number of elements
as matches). With this fix I am able to make my project sucessfully.

I am working on a large project and am unable to extract all makefiles from it as an
example.

Regards,

Ian

--
Ian Willis
Digital Broadcast Systems
Philips Semiconductors Systems Laboratory, Southampton
email: [EMAIL PROTECTED] tel: +44 (0)23 80702701

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Updated the item)
  • -unavailable- added by bosk (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 28 Jul 2010 06:13:19 AM UTCpsmithFixed Release4.0=>3.82
    Thu 28 Jan 2010 07:22:28 AM UTCboskStatusNone=>Fixed
      Open/ClosedOpen=>Closed
      Fixed ReleaseNone=>4.0

    Back to the top


    Powered by Savane 3.1-cleanup1