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

 
 

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

Submitter:  Rafi Einstein <rafi_einstein>
Submitted:  Wed 11 Jul 2007 09:12:44 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.0 Operating System:  Any
Fixed Release:  3.82 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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:

d->name = strcache_add_len (variable_buffer, o - variable_buffer);


Patch attached.

(file #13338)

Paul D. Smith <psmith>
Group administrator
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 Files:
   
   
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
  • -email is unavailable- added by psmith (Updated the item)
  • -email is unavailable- added by rafi_einstein (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-07-28 psmith Fixed Release4.0 3.82
    2007-07-14 psmith Attached 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.13-d3ae.
    Corresponding source code