bugmake - Bugs: bug #29253, Memory corruption error when...

 
 

bug #29253: Memory corruption error when backslash line continuation used in function call

Submitted by:  None
Submitted on:  Thu 18 Mar 2010 08:26:54 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: DuplicatePrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 3.81Operating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 01 Jul 2010 06:20:04 AM UTC, comment #2:

Thanks for the report; this bug has been fixed already in the source and will be included in the next release of GNU make.

Paul D. Smith <psmith>
Project Administrator
Sun 21 Mar 2010 06:08:41 PM UTC, comment #1:

Please note that bcopy is marked as LEGACY in POSI, it is perhas better to use memmove, as suggested in the man page for bcopy.
Here is an equivalent patch from : Roderich Schupp <roderich.schupp@googlemail.com>

--- make-dfsg-3.81-ORIG/job.c 2010-02-06 18:38:32.000000000 +0100
+++ make-dfsg-3.81/job.c 2010-02-06 18:40:56.000000000 +0100
@@ -1594,7 +1594,7 @@
/* There are no more references in this line to worry about.
Copy the remaining uninteresting text to the output. */
if (out != in)
- strcpy (out, in);
+ memmove(out, in, strlen(in)+1);

/* Finally, expand the line. */
lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],

Manoj Srivastava <srivasta>
Thu 18 Mar 2010 08:26:54 AM UTC, original submission:

I ran into some weird behaviour, and with the help of valgrind, tracked it to a misuse of strcpy in the code which elides backslash-newline sequences inside function calls.

The problem is that strcpy explicitly does not support being called with a source and destination that overlap, but make does this. This didn't cause a problem for me on Linux i386, but corrupted the command string on Linux amd64 for me. I suspect that libc is able to use a wider block-at-a-time primitive to implement strcpy on amd64 than i386.

The fix is simple, just convert the strcpy call to a bcopy call:
--- make-dfsg-3.81.orig/job.c
+++ make-dfsg-3.81/job.c
@@ -1594,7 +1594,7 @@
/* There are no more references in this line to worry about.
Copy the remaining uninteresting text to the output. */
if (out != in)
- strcpy (out, in);
+ bcopy (in, out, strlen (in) + 1);

/* Finally, expand the line. */
lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #19974:  make-fix.patch added by None (403B - text/x-patch - Same patch as in comment, attached to preserve whitespace)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by srivasta
  • -unavailable- added by srivasta (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
    Thu 01 Jul 2010 06:20:04 AM UTCpsmithStatusNone=>Duplicate
      Open/ClosedOpen=>Closed
    Sun 21 Mar 2010 06:21:24 PM UTCsrivastaCarbon-Copy-=>Added -unavailable-
    Thu 18 Mar 2010 08:27:50 AM UTCNoneAttached File-=>Added make-fix.patch, #19974

    Back to the top


    Powered by Savane 3.1-cleanup1