www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10338] New: Bug in link.c:107

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10338

           Summary: Bug in link.c:107
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: maxim maxim-fomin.ru



---
From link.c:

int findNoMainError(int fd)
{
    static const char nmeErrorMessage[] =
#if __APPLE__
        "\"__Dmain\", referenced from:"
#else
        "undefined reference to `_Dmain'"
#endif
        ;

    FILE *stream = fdopen(fd, "r");
    if (stream == NULL) return -1;

    const size_t len = 64 * 1024 - 1;
    char buffer[len + 1]; // + '\0'
    size_t beg = 0, end = len;


Buffer is object of automatic lifetime, and it is not initialized, hence it
effectively contains 64 garbage from stack, which may potentially corrupt data.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10338


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



---
Actually it is initialized later, but not fully and code in loop references
data after position fulled by fread() which leads to garbage debug printfs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10338




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8d1dca46e0aab241856aeae87225bdf5e4c9864d
Fix issue 10338

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 12 2013