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

 
 

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

Submitter:  None
Submitted:  Thu 18 Mar 2010 08:26:54 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  3.81 Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
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
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by srivasta
  • -email is unavailable- added by srivasta (Posted a comment)
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2010-07-01 psmith StatusNone Duplicate
        Open/ClosedOpen Closed
    2010-03-21 srivasta Carbon-Copy- Added -email is unavailable-
    2010-03-18 None Attached File- Added make-fix.patch, #19974

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code