bugmake - Bugs: bug #20452, Incorrect use of...

 
 

bug #20452: Incorrect use of variable_buffer_output() in expand_deps() [file.c]

Submitted by:  Rafi Einstein <rafi_einstein>
Submitted on:  Wed 11 Jul 2007 09:12:44 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 4.0Operating 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.

 

Sat 14 Jul 2007 02:52:29 AM UTC, comment #1:

You're absolutely right. Good catch. One note: your fix for the second case is incorrect; it should be:

Patch attached.

(file #13338)

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Wed 11 Jul 2007 09:12:44 PM UTC, original submission:

In expand_deps() [file.c], we do:

char *p;
...
p = variable_expand ("");
variable_buffer_output (p, d->name, strlen (d->name) + 1);

and then use p as if it was pointing to the beginning of the variable buffer (aka variable_buffer).
For a large enough string (16KB will do), variable_buffer_output() will reallocate the variable buffer, leaving p pointing to dark places.
What we should be doing following the variable_buffer_output() call is:
p = variable_buffer;

Subsequently, we do:
char *buffer = variable_expand ("");
o = subst_expand (buffer, d->name, "%", "$*", 1, 2, 0);
d->name = strcache_add_len (buffer, o - buffer);

Again, assuming 'buffer' represents the beginning of the variable buffer.
We should rather write:
d->name = strcache_add_len (o, o - variable_buffer);

Rafi Einstein <rafi_einstein>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #13338:  make-20452.diff added by psmith (896B - text/x-patch)

 

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 rafi_einstein (Submitted the item)
  •  

    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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 28 Jul 2010 06:18:26 AM UTCpsmithFixed Release4.0=>3.82
    Sat 14 Jul 2007 02:52:29 AM UTCpsmithAttached File-=>Added make-20452.diff, #13338
      StatusNone=>Fixed
      Assigned toNone=>psmith
      Open/ClosedOpen=>Closed
      Fixed ReleaseNone=>4.0

    Back to the top


    Powered by Savane 3.1-cleanup1